I want to retrieve the data using python
This is the following code. Please tell me where am I doing wrong.
##create authentication request URL, message and header
authenMsg = {'CreateServiceToken_Request_1': { 'ApplicationID':appid, 'Username':username,'Password':password }}
headers = {'content-type': 'application/json;charset=utf-8'}
result = requests.post(authenURL, data = json.dumps(authenMsg), headers=headers)
try:
if result.status_code == 200:
print('response status %s'%(result.status_code))
token = result.json()['CreateServiceToken_Response_1']['Token']
print('Token: %s'%(token))
expire = result.json()['CreateServiceToken_Response_1']['Expiration']
else:
print('response status %s'%(result.status_code))
if result.status_code == 500: ## if username or password or appid is wrong
print('Error: %s'%(result.json()))
result.raise_for_status()
except requests.exceptions.RequestException as e:
print('Exception!!!')
print(e)
sys.exit(1)
headers_ = {
"POST": "/api/Fundamentals/Fundamentals.svc HTTP/1.1"
,"Content-Type": "application/soap+xml"
,"Host": "api.trkd.thomsonreuters.com"
,"Content-Length": "1"
,'X-Trkd-Auth-Token': token
}
url = "http://api.trkd.thomsonreuters.com/api/Fundamentals/Fundamentals.svc"
r = requests.post(url, data = json.dumps(authenMsg), headers=headers_)
print(r)