Please help me with a question about WC1 API and special characters

Hello, I was testing our implementation in Java with a simple request to the Pilot environment, using a POST request to the uri (rms-world-check-one-api-pilot.thomsonreuters.com/v1/cases) and was getting a response back with the unauthorized 401 error when I sent a name with special character. But this error only happend when I sent a name with special character like in the example:

{ ... "providerTypes":["WATCHLIST"], "name":"Tést" }

If I send a company name without special character, the test works. Testing in postman it works even with special character, but I can't see why. Thanks Vitor

Best Answer

  • Hi @vitor.valerio,

    You must ensure your code is utf-8 and the byte count is encoded.

    var contentLength = unescape(encodeURIComponent(content)).length;

    Hope this helps,
    Brian

Answers

  • I set the content length like this:
    "return text.getBytes().length;"

    and returned the same value of postman

  • Hi @vitor.valerio,

    In java you can handle special character using below line of code.

    String value = new String(jsonBody.getBytes("UTF-8"))

    The value of jsonBody is given below.

    String jsonBody = "{\"secondaryFields\":[],\"entityType\":\"INDIVIDUAL\",\"customFields\":[],\"groupId\":\"418f28a7-b9c9-4ae4-8530-819c61b1ca6c\",\"providerTypes\":[\"WATCHLIST\"],\"name\":\"Tést\"}";

    Hope this helps.

    Thanks,

    Shilpi