DSS PriceHistoryReportTemplate - issue with Condition (ReportDateRangeType)

maja.marevic
maja.marevic Newcomer
edited May 23 in TRTH


{"@odata.type": "#DataScope.Select.Api.Extractions.ReportTemplates.PriceHistoryReportTemplate", "ShowColumnHeaders": true, "Name": "Test", "Headers": [], "Trailers": [], "ContentFields": [{"FieldName": "Ask Price"}, {"FieldName": "Bid Price"}], "Condition": {"ReportDateRangeType": "Range"}}


resp = {'error': {'message': 'Validation Error:\r\n\r\nCondition ReportDateRangeType must be Range, Delta, or Relative'}}

I am having python script which creates instrument list and attempts to create template. I pasted how my json looks like and what I get ass error message.
Any idea what I am doing wrong here? Also tried with DataScope.Select.Api.Extractions.ExtractionsResult/Raw but nothing works as ReportDateRangeType is not a string but enum. Not sure how to approach it.

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @maja.marevic

    Thank you for reaching out to us.

    I tested it on Postman with the https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/PriceHistoryReportTemplates endpoint.

    {
    "@odata.type": "#DataScope.Select.Api.Extractions.ReportTemplates.PriceHistoryReportTemplate",
    "ShowColumnHeaders": true,
    "Name": "Test",
    "Headers": [],
    "Trailers": [],
    "ContentFields": [
    {
    "FieldName": "Ask Price"
    },
    {
    "FieldName": "Bid Price"
    }
    ],
    "Condition": {
    "ReportDateRangeType": "Range",
    "QueryStartDate": "2024-03-01",
    "QueryEndDate": "2024-04-23"
    }
    }

    It works fine.

    image.png

    The Python code looks like this:

    import requests
    import json
    
    url = "https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/PriceHistoryReportTemplates"
    
    payload = json.dumps({
      "@odata.type": "#DataScope.Select.Api.Extractions.ReportTemplates.PriceHistoryReportTemplate",
      "ShowColumnHeaders": True,
      "Name": "Test",
      "Headers": [],
      "Trailers": [],
      "ContentFields": [
        {
          "FieldName": "Ask Price"
        },
        {
          "FieldName": "Bid Price"
        }
      ],
      "Condition": {
        "ReportDateRangeType": "Range",
        "QueryStartDate": "2024-03-01",
        "QueryEndDate": "2024-04-23"
      }
    })
    headers = {
      'Prefer': 'respond-async',
      'Content-Type': 'application/json',
      'Authorization': 'Token  <token>'
    }
    
    response = requests.request("POST", url, headers=headers, data=payload)
    
    print(response.text)