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

tashiro
tashiro Newcomer

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.

Best Answer

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

Answers