Unable to fetch Market Quotes using Python


Dear Team,
Although I am passing the correct instrument_key(“NSE_INDEX|Nifty 50”) ,I am getting an error, could you please check and let me know, what I am missing.
TIA

My code (Python):
import requests
access_token = json_response[‘access_token’]

url = “https://api.upstox.com/v2/market-quote/quotes

payload={
“instrument_key”: “SE_INDEX|Nifty 50”
}
headers = {
“Api-Version”: “2.0”,
“Authorization”: f"Bearer {access_token}",
“Accept”: “application/json”
}

response = requests.request(“GET”, url, headers=headers, data=payload)

print(response.text)

Below is the code for retrieving the Nifty 50 market quotes. Please be assured that this code has been tested and is functioning properly.

import requests
import json

quotesUrl  = "https://api-v2.upstox.com/market-quote/quotes?instrument_key=NSE_INDEX|Nifty 50"
accessToken = "{your_access_token}"

headers = {
    "accept": "application/json",
    "Api-Version": "2.0",
    "Content-Type": "application/x-www-form-urlencoded",
    "Authorization" : f"Bearer {accessToken}"
}
response = requests.get(quotesUrl, headers=headers)

Thanks it is working.