1

I am using the following code for request:

import requests
import print
import json

api_key = "XXX-XXX"
api_version = 'v3'
accountID = "XXX"
tradeID = "XX"

#Endpoint Parts
api_base_url = f"https://api-fxpractice.oanda.com/"
key_url = f"https://api-fxpractice.oanda.com/v3/accounts"
headers = {
    'Authorization': f'bearer {api_key}',
    'Content-Type': 'application/json'
}

data = {'units': 'ALL'}

endpoint_path = f"/{api_version}/accounts/{accountID}/trades/{tradeID}/close"
endpoint = f"{api_base_url}{endpoint_path}"
r = requests.put(endpoint, headers=headers, data=data)
print(r.status_code)
pprint.pprint(r.json())

Response I get:

400
{'errorMessage': "Invalid value specified for 'Authorization'"}
Ruli
  • 2,592
  • 12
  • 30
  • 40
John Doe
  • 47
  • 6

0 Answers0