question

Upvotes
Accepted
262 12 15 18

​I am trying to run some tests on TRTH v2 with the REST API receives 400 Bad Request

I am trying to run some tests with the REST API and I am running into issues. Here is my request and response:


POST https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/ExtractRaw
Authorization: Token _ZMTjszC_E1-FiDGK8UsSxrNw48pQigMcHVlIbeQGf3bhN4BOgnMGcYi_ZNhGYaAvDlQiTisxA3DraV5_qVR4H5PNti1TaAGS1LVyTg9sRvVCF4xINDMgSZjgOmn-txWQwqT9g6H3cJ78cvLTMy_6MNBbvT9yRv5KjcL8jd_L5VuC2wnk45ehU5HTkD5s2v-rP5ixRXMtLvIDdTNvOImssBfyUUy8NjoxPOZySkgE6utBXF7NmC4Ybc6uY9HiAJxW2nQPOxoDb4uAbC4J7LWbIYas3bi4VEaaq-OaB9ZhAMQ
Content-Length: 0
Content-Type: application/json; odata=minimalmetadata
Prefer: respond-async

{"ExtractionRequest":{"ContentFieldNames":["Trade - Price","Trade - Volume"],"@odata.type":"#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.TickHistoryTimeAndSalesExtractionRequest","Condition":{"DisplaySourceRIC":"false","QueryStartDate":"2017-01-01T09:00:00.000","ReportDateRangeType":"Range","ApplyCorrectionsAndCancellations":"true","MessageTimeStampIn":"GmtUtc","QueryEndDate":"2017-01-01T10:00:00.000"},"IdentifierList":{"":"UseUserPreferencesForValidationOptions","InstrumentIdentifiers":[],"false":null,"HASH(0x11d72030)":"ValidationOptions","@odata.type":"#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.InstrumentIdentifiersList"}}}

WARNING: Bad request for url: https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/ExtractRaw
400 Bad Request
{"error":{"message":"Malformed request payload: Syntax error at Line 1, Char 59: Invalid array element type for property 'ContentFieldNames'. Expected element type of 'ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.ExtractionRequestBase', but found 'System.String'. {\"ExtractionRequest\":{\"ContentFieldNames\":[\"Trade - Pric"}}

I see this reported here: https://community.developers.refinitiv.com/questions/10093/dss-rest-api-error-400-malformed-request-payload.html

A JSON object is defined as a set of unordered name/value pairs. The reliance of TRTH API on ordered dictionary is a serious problem because it means you cannot use standard JSON libraries to create your requests.

This was first reported back in November. I am wondering if any progress has been made on fixing it?

tick-history-rest-api
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.

Thank you for your participation in the forum.
Is the reply below satisfactory in resolving your query? If yes please click the 'Accept' text next to the reply. This will guide all community members who have a similar question. Otherwise please post again offering further insight into your question.
Thanks,
-AHS

Upvotes
Accepted
32.2k 40 11 20

Clarification from the content team:

"

The Rest API uses ASP.NET Web API which is Microsoft’s implementation of OData specifications.

It’s in the OData specification to specify the odata.type of a JSON object or name/value pair. Please refer to odata json format doc for more details on odata.type annotation. The odata.type annotation should precede that particular type’s properties. However the properties for that type can be unordered. Said differently, the type annotation must be the first item after the complex type’s opening bracket, so the OData standard requires the JSON to be non-conformant.

"
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
262 12 15 18

Hi Team, can I have an update on this please ? Basing on one of the old post on Dev Community <https://community.developers.refinitiv.com/questions/13604/i-am-getting-this-error-http11-400-bad-request-att.html>;

I had suggested client to rerun the code on Postman tool , here is the client response :

I can confirm now that the issue is with the ordering of the JSON data. My query works when I hardcode the ordering using ordered hashes. Simply changing the order again causes it to break with the same error.

Relying on the user to code around this behavior is bad practice and I would strongly advise your developer teams to fix this. Otherwise all developers will have to do some hacky coding rather than using standard json libraries.

Please look into this on priority and provide an update.

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
32.2k 40 11 20

Hi @Beera.Rajesh,

I have submitted your inquiry to the content team, and will update with any response.

For now, please continue using the expected order.

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 @zoya.farberov

Have you received any response yet? The question remains unanswered.

Hello @zoya.farberov,

I'd like to follow up this problem. If the problem has been fixed, there should be a notification. So, the question can be marked as answered.

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.