Market data Bad request error
-
import http.client
import json
conn = http.client.HTTPSConnection("apiconnect.angelbroking.com")payload = {'mode': 'FULL','exchangeTokens': { 'NSE': ['3045']}}
#payload = '{"mode":"OHCL","exchangeTokens":{"NSE":["26000"]}}'
#payload = "{\r\n "mode": "FULL",\r\n "exchangeTokens": { "NSE": ["3045"] }\r\n}"headers = {
'X-PrivateKey': 'i4YYng1g',
'Accept': 'application/json',
'X-SourceID': 'WEB',
'X-ClientLocalIP': '192.168.168.168',
'X-ClientPublicIP': '106.193.147.98',
'X-MACAddress': 'fe80::216e:6507:4b90:3719',
'X-UserType': 'USER',
'Authorization':'Bearer eyJhbGciOiJIUzUxMiJ9.eyJ1c2VybmFtZSI6IkExMjk3ODkwIiwicm9sZXMiOjAsInVzZXJ0eXBlIjoiVVNFUiIsInRva2VuIjoiZXlKaGJHY2lPaUpTVXpJMU5pSXNJblI1Y0NJNklrcFhWQ0o5LmV5SjFjMlZ5WDNSNWNHVWlPaUpqYkdsbGJuUWlMQ0owYjJ0bGJsOTBlWEJsSWpvaWRISmhaR1ZmWVdOalpYTnpYM1J2YTJWdUlpd2laMjFmYVdRaU9qTXNJbk52ZFhKalpTSTZJak1pTENKa1pYWnBZMlZmYVdRaU9pSTBOR0V4TjJaaVppMDFaVFJpTFRNeE9URXRPRFU0WXkxaVpEYzFObVF3WVRSa01USWlMQ0pyYVdRaU9pSjBjbUZrWlY5clpYbGZkakVpTENKdmJXNWxiV0Z1WVdkbGNtbGtJam96TENKd2NtOWtkV04wY3lJNmV5SmtaVzFoZENJNmV5SnpkR0YwZFhNaU9pSmhZM1JwZG1VaWZYMHNJbWx6Y3lJNkluUnlZV1JsWDJ4dloybHVYM05sY25acFkyVWlMQ0p6ZFdJaU9pSkJNVEk1TnpnNU1DSXNJbVY0Y0NJNk1UY3lNVEk0TlRJMk9Dd2libUptSWpveE56SXhNVGswT1RFNUxDSnBZWFFpT2pFM01qRXhPVFE1TVRrc0ltcDBhU0k2SW1Ka016azROVEkwTFRBeVpUa3ROREl5TUMxaVpqTTJMV0UyTm1Wak5HUm1NakkxTnlKOS5JM0lEbUFiSzVRVktYbGtTX2FFNU9wQ0xnX05hZ2hWTllTR0pUQlRTS0ZibzBBOUpLN0laWVR0QzBCNDdnenBLTDFxeHB2akwxMzhfRzNTLWVpWkVGV3FsdEtGbjZpdFNpc0NrWDBEWW5DRXo3dC1RenhnQ1llZ3MxQ2h4REh2aF9NQkU1LXZ2NXIxVmpkZ2M1Um5oSnM3ZF9hdEg2T205Nzd4NmxFT2hhbk0iLCJBUEktS0VZIjoiaTRZWW5nMWciLCJpYXQiOjE3MjExOTQ5NzksImV4cCI6MTcyMTI4NTI2OH0.thPS8dq0zTtx-IWGTW4afvSYNfQz52qEs940Rg0UCIePe8ZStteLZhZH3s1kFmu4UH4YQhFWH2Su_-mmC1EW-A',
'Accept': 'application/json',
'X-SourceID': 'WEB',
'Content-Type': 'application/json'
}
conn.request("POST", "rest/secure/angelbroking/market/v1/quote/",json.dumps(payload), headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))