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

Overview |  Quickstart |  Documentation |  Downloads

question

Upvotes
Accepted
1 2 3 1

Need Java Code For World Check API

Dear Team,

I download the code from download tab from developer community. for use that java code able to retrieve the values for SEQ 1a and SEQ 2b. And not able to retrieve the remaining functions for ex: SEQ 1b,SEQ-1c,SEQ-4a,SEQ-5b,SEQ-5c. and also we getting "HTTP/1.1 401 Unauthorized" Error.

Please help us. and find my code below for reference.

Java Code:

String jsonBody1 = "{\"secondaryFields\":[],\"entityType\":\"INDIVIDUAL\",\"customFields\":[],\"groupId\":"+groupid+",\"providerTypes\":[\"WATCHLIST\"],\"name\":\"george w bush\"}";

// create a JSON object from the JSON

string JSONObject jo = new JSONObject(jsonBody1);

//System.out.println(jo.toString());

String jlen = String.valueOf(jo.toString().length());

//SEQ-4a-postscreencase

String dataToSign = "(request-target): post " + gatewayurl + "cases/" + casesystemid + "/screeningRequest\n" + "host: " + gatewayhost + "\n" + "date: " + date + "\n" + "content-type: " + "application/json" +"\n" + "content-length: " + jlen + "\n" + jo;

//SEQ-2b-postsavesimplecase

String hmac = generateAuthHeader(dataToSign, apisecret);

String authorisation = "Signature keyId=\"" + apikey + "\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date content-type content-length\",signature=\"" + hmac + "\""; System.out.println("jlen : "+jlen);

System.out.println("dataToSign : "+dataToSign);

System.out.println("hmac : "+hmac);

System.out.println("authorisation : "+authorisation); String msg = jo.toString();

HttpPost httpPost = new HttpPost("https://rms-world-check-one-api-pilot.thomsonreuters.com/v1/cases");

HttpEntity entity = new StringEntity(msg); httpPost.setEntity(entity);

httpPost.addHeader("Date", date);

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

httpPost.addHeader("Content-Type", "application/json" );

httpPost.addHeader("Authorization", authorisation);

// send the POST request CloseableHttpResponse response1 = httpclient.execute(httpPost);

try { HttpEntity entity1 = response1.getEntity();

System.out.println("response1.getStatusLine() : "+response1.getStatusLine());

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

world-checkworld-check-one
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.

1 Answer

Upvotes
Accepted
3.1k 18 7 7

Hi @sanjay.mishra,

We do not support IDE/Language environments nor the development of your application. The code examples in the Downloads section are for example only and as you point out they work. You'll need to read the documentation on how to make requests to the other endpoints. Look at the Postman collection examples in detail, each request has different environment settings and pre-Request Script, then compare to the example Java code, you should see your coding errors.

Brian

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.