For a deeper look into our DataScope Select REST API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials

question

Upvotes
Accepted
1 0 0 0

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





dss-rest-apipython apirequest-token
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.

Upvote
Accepted
286 3 2 5

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

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
16.8k 31 9 12

Hello @ram5s

While my colleague has provided a clear answer and example for you, you can find more information about the DSS REST API development from the API tutorials page

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
52.9k 136 44 63

@ram5s

You can also refer to the Generate code for a REST API call using Postman in just a few clicks article which demonstrates how to use Postman to generate Python code from the DSS collection.

1662027858111.png

You can download the DSS REST Tutorials Postman collection and use it to generate Python code.


1662027858111.png (121.5 KiB)
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.