errorCode': 'UDAPI10000', This request is not supported by Upstox API

Below is my Python code, giving errorCode’: ‘UDAPI10000’, This request is not supported by Upstox API

import urllib.parse
import pandas as pd
import requests

apikey = ‘’
secretkey = ‘’
url1 = urllib.parse.quote(‘https://127.0.0.1:5001/’)

url = ‘https://api-v2.upstox.com/login/authorization/token
code=‘’
headers = {
‘accept’: ‘application/json’,
‘Api-Version’: ‘2.0’,
‘Content-Type’: ‘application/x-www-form-urlencoded’
}
data = {
‘code’: code,
‘client_id’: apikey,
‘client_secret’: secretkey,
'redirect_uri ': url1,
‘grant_type’: ‘authorization_code’
}
response = requests.post(url, headers=headers, data=data)
jsonresponse = response.json()

jsonresponse

@anil_chorghe

Please pass the redirect_uri as is without encoding.

Let us know if that works.

Thanks!!

Thanks Shanmu, the issue is sorted

1 Like

I have below python code, but it isnt working.

PYTHON CODE

import upstox_client

import requests
from time import sleep
import xlwings as xw

global api_key, secret_key, r_url, topt_key, mobile_no, pin

wb = xw.Book(‘TradeToolsUpstox.xlsx’)
crd = wb.sheets(“Cread”)
api_key = crd [‘B1’].value
secret_key = crd [‘B2’].value
r_url = crd [‘B3’].value
topt_key = crd [‘B4’].value
mobile_no = crd [‘B5’].value
pin = crd [‘B6’].value
auth_url = f’https://api.upstox.com/v2/login/authorization/dialog?response_type=code&client_id={api_key}&redirect_uri={r_url}

#code = urlparse.parse_qs(parsed.query)[‘code’][0]
url = ‘https://api.upstox.com/v2/login/authorization/token

code=‘’

headers = {
‘accept’: ‘application/json’,
‘Api-Version’: ‘2.0’,
‘Content-Type’: ‘application/x-www-form-urlencoded’}

payload = {
‘code’: code,
‘client_id’ : api_key,
‘client_secret’: secret_key,
‘redirect_uri’: r_url,
‘grant_type’: ‘authorization_code’}

response = requests.post(url, headers=headers, data=payload)
if response.status_code == 200:
token = response.json().get(“access_token”)
print(“Access Token:”, token)
jsr = response.json()

with open ('accessToken.txt','w') as file:
    file.write(jsr['access_token'])
print(f"Access Token : {jar['access_token']}")

else:
print(“Failed to get token:”, response.status_code, response.text)

================================================

ERROR BELOW:

Failed to get token: 400 {“status”:“error”,“errors”:[{“errorCode”:“UDAPI10000”,“message”:“This request is not supported by Upstox API”,“propertyPath”:null,“invalidValue”:null,“error_code”:“UDAPI10000”,“property_path”:null,“invalid_value”:null}]}

@Zainab_Aalia,

Thank you for reaching out.

It appears your request is not in the expected format.

Please refer to the following cURL sample for generating the token: Get Token.

I hope this helps.

Thanks!

hi, this is python code first of all. Second I have very advance code now. Which can login, fetch multiple apps and be in sync. All working perfectly.