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());