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();
}
}
}
Answers
-
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)
0 -
the error is : Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input
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
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.
0
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛