For a deeper look into our DataScope Select REST API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials

question

Upvotes
Accepted
1 1 0 0

Read timed out - End of Day price data

Requirements: We want End of Day price from DSS
Technology : Salesforce
DSS REST API Service : https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/ExtractWithNotes
Issue : System.CalloutException: Read timed out
Expected API: Instead of timeout can you send us ExtractionID and Data "Example: ExtractionId='0x053b21c6eadb5821'" as a response body. we will retrieve data from DSS REST AOU "ExtractResult(ExtractionId='0x053b21c6eadb5821'


Sample code


request.setTimeout(120000); //Maximum in milliseconds
request.setMethod('POST');
request.setHeader('Content-Type', 'application/json');
request.setHeader('Prefer','respond-async');
request.setHeader('Authorization',userAuthResponseSessionToken);
HttpResponse response = http.send(request); //Getting Timeout from DSS
system.debug('Status Code is '+response.getStatusCode()); //Exception thorwn above line, hence don't get status code here as 202 Accepted or 200 etc
String resultBody = response.getBody();
System.debug(Logginglevel.DEBUG,response.getBody());

dss-rest-apidssdatascope-select
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.

@abhishek.tripathi, could you please:

  • Post the full body of your POST request ? (This can be done as an attachment if it is large)
  • Tell us if the timeout happens systematically or only occasionally ?

That would help us debug the issue you are facing.

Upvotes
Accepted
13.7k 26 8 12

Answer by Veerapath, copied here to be able to close the thread:

The error indicates that the value in the Authorization header is incorrect. The Authorization header needs to start with "Token" string. Please modify the code as follows.

request.setHeader('Authorization','Token'+ usrAuthResponseSession); 
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 0 0

As requested, Please find detail source code for post request and debug response message for more analysis for your side.

This timeout is getting always I did not get a success response from DSS for given API.

looking forward your response asap.

try{
system.debug('Invoke ExtractWithNotes END Point');
String endPointURL = 'https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/ExtractWithNotes';
Httprequest request = new HttpRequest();
Http http = new Http();
request.setTimeout(120000); //Maximum
request.setMethod('POST');
request.setHeader('Content-Type', 'application/json');
//request.setHeader('Content-Type', 'application/json; odata=minimalmetadata; charset=utf-8');
//request.setHeader('Content-Length', '40960');
request.setHeader('Prefer','respond-async'); //[{"key":"Prefer","value":"respond-async","enabled":true}]
request.setHeader('Authorization',usrAuthResponseSession);
request.setEndpoint(endPointURL);
HttpResponse response = http.send(request);
system.debug('Status Code is '+response.getStatusCode());

String resultBody = response.getBody();
System.debug(Logginglevel.DEBUG,response.getBody());
system.debug('responseBody: '+response.getBody());
//Logic to Parse JSON response received from reuters DSS API
//
system.debug('Begin Json Parser.............');
}catch(Exception e){
system.debug(' Exception thorwn ExtractWithNotes at line no '+e.getLineNumber()+' with message as '+e.getMessage());


}

Debug Logs :

10:47:32.705 (1714711814)|USER_DEBUG|[33]|DEBUG|Invoke ExtractWithNotes END Point
10:47:32.705 (1714914452)|CALLOUT_REQUEST|[45]|System.HttpRequest[Endpoint=https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/ExtractWithNotes, Method=POST]
10:49:32.817 (121817001599)|EXCEPTION_THROWN|[45]|System.CalloutException: Read timed out
10:49:32.817 (121817293268)|USER_DEBUG|[55]|DEBUG| Exception thorwn ExtractWithNotes at line no 45 with message as Read timed out
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.

Hi @abhishek.tripathi,

The ExtractWithNotes requires request's body. From the code, I cannot see the .setBody() method. Could you verify and add the body of the request?

Upvotes
1 1 0 0

As requested, I have added setbod with json default value provided by refinitive doc. Now error message is "

{"error":{"message":"The Authorization header is malformed. Supported Authorization types are Token,Basic."}}

try{
system.debug('Invoke ExtractWithNotes END Point');
String endPointURL = 'https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/ExtractWithNotes';
Httprequest request = new HttpRequest();
Http http = new Http();
request.setTimeout(120000); //Maximum
request.setMethod('POST');
//request.setHeader('Content-Type', 'application/json');
request.setHeader('Content-Type', 'application/json; odata=minimalmetadata; charset=utf-8');
request.setHeader('Content-Length', '40960');
request.setHeader('Prefer','respond-async'); //[{"key":"Prefer","value":"respond-async","enabled":true}]
request.setHeader('Authorization',usrAuthResponseSession);
request.setEndpoint(endPointURL);
String jsonBody = '{"ExtractionRequest":{"@odata.type":"#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.EndOfDayPricingExtractionRequest","ContentFieldNames":["Ask Price","Asset Category","Asset Category Description","Asset ID","Asset Status","Asset Status Description","Asset SubType","Asset SubType Description","Asset Type","Asset Type Description","Bid Price","Block Trades","CIN Code","Common Code","Currency Code","Currency Code Description","Currency Code Scaled","Currency Code Scaled Description","CUSIP","Exchange Code","Exchange Description","Exercise Style","Expiration Date","File Code","High Price","Instrument ID","Instrument ID Type","ISIN","Issuer OrgID","Lot Size","Low Price","Market MIC","MIC","Mid Price","Net Asset Value","Number of Price Moves","Offer Price","Official Close Price","Open Price","Previous Close Price","Put Call Indicator","Quote ID","RCP ID","RIC","Security Description","SEDOL","Settlement Date","Settlement Price","SICC","Sicovam","Strike Price","Ticker","Trade Date","Trading Status","Trading Symbol","Turnover","Underlying RIC","Universal Ask Price","Universal Bid Ask Date","Universal Bid Price","Universal Close Price","Usage Instrument SubType","Usage Instrument Type","Valoren","Volume","VWAP Price","Wertpapier"],"IdentifierList":{"@odata.type":"#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.InstrumentIdentifierList","InstrumentIdentifiers":[{"Identifier":"438516AC0","IdentifierType":"Cusip"},{"Identifier":"IBM.N","IdentifierType":"Ric"}]},"Condition":null}}';
request.setBody(jsonBody);
HttpResponse response = http.send(request);
system.debug('Status Code is '+response.getStatusCode());

String resultBody = response.getBody();
System.debug(Logginglevel.DEBUG,response.getBody());
system.debug('responseBody: '+response.getBody());
//Logic to Parse JSON response received from reuters DSS API
//
system.debug('Begin Json Parser.............');
}catch(Exception e){
system.debug(' Exception thorwn ExtractWithNotes at line no '+e.getLineNumber()+' with message as '+e.getMessage());


}

13:15:14.361 (1369227165)|METHOD_EXIT|[29]|01p0w000000U0Ru|CLS_REUTERS_DMCC_RESTIntegration.UserAuthentication()
13:15:14.361 (1369251582)|USER_DEBUG|[30]|DEBUG| User Session is __iBBvv5hKfLUzE4RJkEunTDu8neSdGv8j-k3t53pVbb4dNGyu7oGbg78tu3tEaERYa3zxaijd7zyqzMqg7c0EwsWHl35Yo-aEQwHIzESozsS9PdXWJHIKP4QRyY0dbiD0JpNVmSMS14uav-8GF47gzdPiY1dckVuqUVTqHO3bSyNr-C72_HWpBFUJ7r0rYy8nHIHC8m3pqmQsM3XeIxh9lx5QHq_LXnJ7rw4weHqnLFwmgqs5qKBR4hHHvk2jfZBzwBPSo5FecIYy0RUx2UIICRIreDDcK1nmT3bpNN1BTM
13:15:14.361 (1369270826)|USER_DEBUG|[33]|DEBUG|Invoke ExtractWithNotes END Point
13:15:14.361 (1369498596)|CALLOUT_REQUEST|[47]|System.HttpRequest[Endpoint=https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/ExtractWithNotes, Method=POST]
13:15:14.361 (1751567992)|CALLOUT_RESPONSE|[47]|System.HttpResponse[Status=Unauthorized, StatusCode=401]
13:15:14.361 (1751715552)|USER_DEBUG|[48]|DEBUG|Status Code is  401
13:15:14.361 (1751797366)|USER_DEBUG|[51]|DEBUG|{"error":{"message":"The Authorization header is malformed. Supported Authorization types are Token,Basic."}}
13:15:14.361 (1751830263)|USER_DEBUG|[52]|DEBUG|responseBody: {"error":{"message":"The Authorization header is malformed. Supported Authorization types are Token,Basic."}}
13:15:14.361 (1751857272)|USER_DEBUG|[55]|DEBUG|Begin Json Parser.............
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.

The error indicates that the value in the Authorization header is incorrect. The Authorization header needs to start with "Token" string. Please modify the code as follows.

request.setHeader('Authorization','Token'+ usrAuthResponseSession); 
Upvotes
1 1 0 0

It's working now. Thanks lot for your support.

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.