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.

hi @ram5s ,

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?
If so please can you click the 'Accept' text on the left side of the appropriate reply? This will guide all community members who have a similar question.

Thanks,
AHS

@ram5s

Hi,

Please be informed that a reply has been verified as correct in answering the question, and marked as such.

Thanks,

AHS

Upvote
Accepted
406 6 2 6

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
24.7k 54 17 14

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
78.9k 250 52 74

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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