For a deeper look into our DataScope Select REST API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials

question

Upvotes
Accepted
3 0 0 1

RestApi/v1/Authentication/RequestToken : The response language and CharSet is different

I have integrated the authentication API (https://selectapi.datascope.refinitiv.com/RestApi/v1/Authentication/RequestToken) using JAVA in our springboot application. The issue currently we are facing is with response with this API. The API response status is 200 but the language is not in English with the charSet as UTF-16. Due to this issue we are unable to extract the auth-token to make further calls to fetch data whereas we are seeing no issue while calling the above api from Postman.


Example : 1718972466027.png
We tried to convert the above response to UTF-8 charSet but the result had some unwanted characters, due to which we cannot proceed with this approach.

From Postman :

1718972700557.png


Can anyone suggest any changes that we can make in our application code to get the desired response ?

#technologyapijavaauthenticationresponse
1718972466027.png (66.4 KiB)
1718972700557.png (12.5 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

We are integrating the authentication API in a springboot application and making call to the authentication API using RestTemplate:

ResponseEntity<String> response = restTemplate.postForEntity(loginUrl, requestEntity1, String.class);


Here the login url is the authentication url and request entity contains the request headers & Body

1 Answer

· Write an Answer
Upvotes
Accepted
85.5k 292 53 77

@anubhav.tyagi

Thank you for reaching out to us.

If the request in Postman works fine, the problem may relate to the settings in springboot. I searched in Google and found serveral results regarding the UTF8 setting in springboot.

I tested the UTF16 charset in Java with the Unirest and could get the token properly.

        try {
            HttpResponse<JsonNode> response = Unirest.post("https://selectapi.datascope.refinitiv.com/RestApi/v1/Authentication/RequestToken")
                .header("Prefer", "respond-async")
            .header("Content-Type", "application/json; charset=utf-16")
            .header("Accept", "application/json")
        .body("{\"Credentials\": {\r\n    \"Username\": \"<usrname>\",\r\n    \"Password\": \"<password>\"\r\n  }\r\n}".getBytes(StandardCharsets.UTF_16))
                .asJson();
            System.out.println(response.getHeaders());
            String token = response.getBody().getObject().getString("value");
            System.out.println("Token = "+token);
            
        } catch (UnirestException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        
        }

The output looks like this:

1719299940447.png

The Content-Length of the HTTP response is 812 bytes and the Content-Type is [application/json; charset=utf-16].

The Content-Length of the HTTP response is 405 bytes when the charset is utf-8, as shown below. 1719300365938.png


1719299940447.png (37.9 KiB)
1719300365938.png (31.1 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thanks @Jirapongse, we had implemented this approach and the issue is now resolved

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.