401 response on cases/screeningRequest with python
import requests
import hmac
import hashlib
import base64
import time
import json
# To get the GMT time
stringdataformat = ("%a, %d %b %Y %H:%M:%S GMT")
datenow = time.gmtime()
date = time.strftime(dataformat, datenow)
print(date) api_key = "xxxxxxxxxxxxxxxxxxxx"
# Enter your API key
api_secret = "xxxxxxxxxxxxxxxxxxxxxxx"
# Enter your API secret
group_id = "xxxxxxxxxxxxxxxxxxxxxxx"
# Enter your group Id
api_token = api_secret.encode()
path = "https://rms-world-check-one-api-pilot.thomsonreuters.com/v2/cases/screeningRequest"
gatewayurl = "/v2/"
gatewayhost = "rms-world-check-one-api-pilot.thomsonreuters.com"
content_type = "application/json"
name1 = "putin"
entity_type = "INDIVIDUAL"
bcontent = "{\n\"secondaryFields\": [],\n \"entityType\": \"" + entity_type + "\",\n \"customFields\": [],\n \"groupId\":\"" + group_id + "\",\n \"providerTypes\": [\n \"WATCHLIST\"\n ],\n \"name\": \"" + name1 + "\"}"
content = bcontent.encode('utf-8')length = len(content)
str_length = str(length)
datatosign = "(request-target): post " + gatewayurl + "cases/screeningRequest\n" + \ "host: " + gatewayhost + "\n" + \ "date: " + date + "\n" + \ "content-type: " + content_type + "\n" + \ "content-length: " + str_length + "\n" + \ content.decode()
byte_datatosign = datatosign.encode()
def hbase(byte_datatosign, api_token):
encrypt = hmac.new(api_token, byte_datatosign, digestmod=hashlib.sha256)
digest_maker = encrypt.digest()
base = base64.b64encode(digest_maker)
return base.decode()
hmacbase = hbase(byte_datatosign, api_token)
print(hmacbase)
authorisation = "Signature keyId=\"" + api_key + "\"" + ",algorithm=\"hmac-sha256\"" + ",headers=\"(request-target) host date content-type content-length\"" + ",signature=\"" + hmacbase + "\""
print(authorisation)
headers = { 'Authorization': authorisation, 'Date': date, 'Content-Type': content_type, 'Content-Length': str_length, 'Accept': "*/*", 'Cache-Control': "no-cache", 'Host': "rms-world-check-one-api-pilot.thomsonreuters.com", 'Accept-Encoding': "gzip, deflate", 'Connection': "keep-alive", 'cache-control': "no-cache"}
requests.post(path, data=content, headers=headers)
I'm trying to make a screening request with the following code with python and it keeps returning 401 errors. What am I doing wrong?
Tagged:
0
Best Answer
-
Thank you for your query.
Could you please refer to the python example share in the below link?
Please let us know if you need further assistance.
0
Categories
- All Categories
- 6 AHS
- 39 Alpha
- 162 App Studio
- 4 Block Chain
- 5 Bot Platform
- 17 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 370 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 60 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛