With the help of headers, I am able to call historical candles, and it returns data. However, when I query for margins or try to place an order using the same set of headers, it says “Invalid token used to access API.” Can someone help me?
import requests
access_token= "fav access token"
headers = {
'Accept': 'application/json',
'Authorization': f"Bearer {access_token}",
}
url = "https://api.upstox.com/v2/historical-candle/intraday/NSE_EQ|INE002A01018/1minute"
response = requests.request("GET", url, headers=headers, data={})
print(response.text[:100])
url = "https://api.upstox.com/v2/user/get-funds-and-margin"
response = requests.request("GET", url, headers=headers, data ={})
print(response.text)
{'status': 'success', 'data': {'candles': [['2024-09-24T14:49:00+05:30', 2988, 2988.05, 2986.7, 2986
{"status":"error","errors":[{"errorCode":"UDAPI100050","message":"Invalid token used to access API","propertyPath":null,"invalidValue":null,"error_code":"UDAPI100050","property_path":null,"invalid_value":null}]}