For a deeper look into our World Check One API, look into:

Overview |  Quickstart |  Documentation |  Downloads

question

Upvotes
Accepted
1 1 1 0

Connection Reset in info log and didn’t get any response. What may be the cause?

This is the sample code in API that we use: (*The method is using for retrieve all world check iso country list.)


static String gatewayurl = "/v1/";

static String gatewayhost = "api-worldcheck.refinitiv.com";


public static void processingGetIsoCountryList() throws IOException {

_log.info("Entering the processingGetIsoCountryList method");

CloseableHttpClient httpclient = HttpClients.createDefault();

try {

Date now = new Date();


// format for date string Mon, 27 Mar 2017 15:19:36 GMT

DateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z");

df.setTimeZone(TimeZone.getTimeZone("GMT"));


String date = df.format(now);


String dataToSign = "(request-target): get " + gatewayurl

+ "reference/countries\n" + "host: " + gatewayhost + "\n"

+ "date: " + date;


String hmac = generateAuthHeader(dataToSign, apisecret);

String authorisation = "Signature keyId=\""

+ apikey

+ "\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date\",signature=\""

+ hmac + "\"";


_log.info("dataToSign is......" + dataToSign);

_log.info("hmac is......" + hmac);

_log.info("authorisation is......" + authorisation);


HttpGet httpGet = new HttpGet(httpsUrl + "reference/countries");


httpGet.addHeader("Authorization", authorisation);

httpGet.addHeader("Cache-Control", "no-cache");

httpGet.addHeader("date", date);


CloseableHttpResponse response = httpclient.execute(httpGet);


try {


HttpEntity entity = response.getEntity();

_log.info("response.getStatusLine is.........."+ response.getStatusLine());


String json = EntityUtils.toString(response.getEntity());

_log.info("entity is......." + entity);

_log.info("json is......." + json);

ObjectMapper mapper = new ObjectMapper();


Object jsonObj = mapper.readValue(json, Object.class);

String indented = mapper.writerWithDefaultPrettyPrinter()

.writeValueAsString(jsonObj);

_log.info("indented is..........." + indented);


EntityUtils.consume(entity);

}

catch (Exception e) {

_log.info(e.getMessage());

} finally {

response.close();

}


} catch (Exception e) {

_log.info(e.getMessage());

} finally {

httpclient.close();

}

_log.info("Exiting the processingGetIsoCountryList method");

}




In the API.log, you will notice that after executing the code CloseableHttpResponse response = httpclient.execute(httpGet);

The connection was reset. It didn’t get any response.

This line of code was not called: _log.info("response.getStatusLine is.........."+ response.getStatusLine());



Here's the result in API.log

14:41:37.435 [http-thread-pool-8083(2)] INFO com.tr.worldCheckApi.GetRequest - Entering the processingGetIsoCountryList method

14:41:38.224 [http-thread-pool-8083(2)] INFO com.tr.worldCheckApi.GetRequest - dataToSign is......(request-target): get /v1/reference/countries

host: api-worldcheck.refinitiv.com

date: Mon, 10 May 2021 06:41:38 GMT

14:41:38.224 [http-thread-pool-8083(2)] INFO com.tr.worldCheckApi.GetRequest - hmac is......sCGRBNlS5we5RKGJEr7TARZ60Smy4zXzOujNgeMSEEo=

14:41:38.225 [http-thread-pool-8083(2)] INFO com.tr.worldCheckApi.GetRequest - authorisation is......Signature keyId="1ad3ff6b-2870-4478-bc23-cae4cc4f2422",algorithm="hmac-sha256",headers="(request-target) host date",signature="sCGRBNlS5we5RKGJEr7TARZ60Smy4zXzOujNgeMSEEo="

14:41:42.069 [http-thread-pool-8083(2)] INFO com.tr.worldCheckApi.GetRequest - Connection reset

14:41:42.071 [http-thread-pool-8083(2)] INFO com.tr.worldCheckApi.GetRequest - Exiting the processingGetIsoCountryList method

world-checkworld-check-one
icon clock
10 |1500

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

1 Answer

Upvotes
Accepted
548 1 1 1

@ruberson.tria,

Can you please share the request and the response headers of the failed request? We would need both in order to investigate further on the cause of the error.


icon clock
10 |1500

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

I didn't use request and response headers. I download the World-Check One API Java Request Code and World-Check One API Java v1.2 Collection Tool and incorporate it in our system. I use this to test the connectivity and authorization to the World-Check One API webserver as well as to retrieve information.

I want to check if my Java Code need some update to connect in the World-Check One API webserver.

@ruberson.tria,

Thanks for your response.

The code which you have downloaded is sample code, and may not work if you are using different development component. So I would advise you to please share the request and the response header, as Error 401, could be due to the different in the timestamps between request and response.

Click below to post an Idea Post Idea