Python Cannot Request A Token for DSS

For REST API in Python for Mac, unable to get a response for request token.
I have tried both POST and GET methods.


Error shown is:
,"message":"Resource not found for the segment 'RequestToken HTTP'."}}

Below is the code:


import requests

URL="https://selectapi.datascope.refinitiv.com/RestApi/v1/Authentication/RequestToken HTTP/1.1"


headers={'Prefer': 'respond-async','Content-Type': 'application/json'}

params = {'Username': 'Added_Username', 'Password': 'Added_password'}

response=requests.get(URL, params=params,headers=headers).text





Best Answer

  • gteage
    Answer ✓

    Hi @ram5s

    Using Python requests , the request should look like the below, I think it's just the use of the HTTP/1.1 that isn't expected:


    import requests

    url = "https://selectapi.datascope.refinitiv.com/RestApi/v1/Authentication/RequestToken"

    payload = "{\r\n \"Credentials\": {\r\n \"Username\": \"<UserID>\",\r\n \"Password\": \"<Password>\"\r\n }\r\n}"

    headers = {

    'Prefer': 'respond-async',

    'Content-Type': 'application/json; odata=minimalmetadata'

    }

    response = requests.request("POST", url, headers=headers, data=payload)

    print(response.text)


    Best regards,

    Gareth

Answers