question

Upvotes
Accepted
3 0 0 2

Error 400 malformed request payload: for sample code on REST API

Hi,

I tried to run the attached sample code, trth-ondemand-intradaybarspy.txt

but the following message appeared:

{'error': {'message': "Malformed request payload: '@odata.type' is either missing or misplaced for type ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.ExtractionRequest"}}

I checked the question #34694, and then I updated packages and revised tickers,

but still didn't work. How can I revise the code to work?

I use python 3.5.3 on Mac.

tick-history-rest-apirest-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvotes
Accepted
9.5k 10 5 7

Hello @tashiro

In the file, trth-ondemand-intradaybarspy.txt, at line 79 which is requestBody, at the value of "ContentFieldNames":

requestBody={
  "ExtractionRequest": {
    "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.TickHistoryIntradaySummariesExtractionRequest",
    "ContentFieldNames": [
      "Close Ask",
      "Close Bid",
    ],
...

There is an additional "," after "Close Bid" which makes the wrong syntax. "Close Bid" is the last item so it should not have ",". The correct syntax should be:

requestBody={
  "ExtractionRequest": {
    "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.TickHistoryIntradaySummariesExtractionRequest",
    "ContentFieldNames": [
      "Close Ask",
      "Close Bid"
    ],
...

When I removed "," after "Close Bid" as shown above, the request could be proceeded successfully. I got 202 Accept from the Postman

I suggest you test the requests with the Postman first to verify if the requests are in the correct syntax. You can find TRTH postman requests example in Downloads page of TRTH

Hope this help.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Thank you for your response!

This was the first time for me to use REST API and I didn't know about the Postman. I appreciate your advice.

After I revised the requests and updated python to 3.6, the code worked.

Click below to post an Idea Post Idea