question

Upvotes
1 1 1 1

I got exception: No content to map due to end-of-input

public class GetRequest {


public static String generateAuthHeader(String dataToSign, String secret) {

String hash = "";

try {


Mac sha256_HMAC = Mac.getInstance("HmacSHA256");

SecretKeySpec secret_key = new SecretKeySpec(secret.getBytes(), "HmacSHA256");

sha256_HMAC.init(secret_key);

hash = Base64.encodeBase64String(sha256_HMAC.doFinal(dataToSign.getBytes()));

} catch (Exception e) {

System.out.println("Error");

}

return (hash);

}


// A simple request to create a Case using Http Get

public static void main(String[] args) throws Exception {

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 gatewayurl = "/v2/";

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

String apikey = "XXXXXXXXX-XXXX-XXXX-XXXXX-e5ac69bef305";

String apisecret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";


String dataToSign = "(request-target): get " + gatewayurl + "groups\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 + "\"";


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

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

//System.out.println(authorisation);


HttpGet httpGet = new HttpGet("https://api-worldcheck.refinitiv.com/v2/groups");


httpGet.addHeader("Authorization", authorisation);

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

httpGet.addHeader("date", date);


CloseableHttpResponse response1 = httpclient.execute(httpGet);


try {


HttpEntity entity1 = response1.getEntity();

System.out.println(response1.getStatusLine());


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

System.out.println("entity1 " +entity1);

System.out.println("json" + json);

ObjectMapper mapper = new ObjectMapper();


//StatusResponses loginValidator = null;

ObjectMapper objectMapper = new ObjectMapper();

objectMapper.configure(Feature.AUTO_CLOSE_SOURCE, true);



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

String indented = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonObj);

System.out.println(indented);


EntityUtils.consume(entity1);

} finally {

response1.close();

}


} finally {

httpclient.close();

}

}

}

sanctions
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.

<AHS>

Contacted World-Check team, extend triage.

Hello @jprogrammer

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?


If so please can you click the 'Accept' text next to the appropriate reply? This will guide all community members who have a similar question.

Thanks,


AHS


Upvotes
1 1 1 1

dataToSign (request-target): get /v2/groups

host: api-worldcheck.refinitiv.com

date: Вт, 02 авг 2022 13:14:25 GMT-----------------

hmac is xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

HTTP/1.1 400

entity1 [Content-Length: 0,Chunked: false]

json

Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input

at [Source: ; line: 1, column: 0]

at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:270)

at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:3838)

at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3783)

at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2842)

at getrequest.GetRequest.main(GetRequest.java:101)

C:\Users\SAPPI_WorkBech\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1

BUILD FAILED (total time: 3 seconds)


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.

Upvotes
1 1 1 1

the error is : Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input

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.

Upvotes
984 5 1 5

Hi @jprogrammer

Please let us know the best available time to schedule a session.


Thanks

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.

<AHS>

Hi @anisetti.saikiranreddy ,

Could you please let us know if this question has been answered off the forum already?

Thanks,
AHS

Upvotes
1 0 0 0

Hi Team,

I am also facing same error. Can you please come in a session.

No content to map due to end-of-input


Regards,

Rajesh

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.

Upvotes
1 0 0 0

Adding to the previous query: One note is that same java code is working when i run locally in my laptop, it is not working in customer premise.

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.

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.