Hi Lohitha,
Did you check if the app ID which is passed is correct?
header is correct, for authorization it should be passed as app_id:access_token
Question
FYERS API Order placing error
Trying to place market order but failing with "Please provide a valid app id.", , "id": "" but app is active. I might be wrong with the header. is the header is correct?
app_id = 'LD8XXXATGA-100'
access_token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcGk................N9o'
conn = http.client.HTTPSConnection("api.fyers.in")
payload = json.dumps({
"symbol": "NSE:ONGC-EQ",
"qty": 1,
"type": 2,
"side": 1,
"productType": "INTRADAY",
"limitPrice": 0,
"stopPrice": 0,
"validity": "DAY",
"disclosedQty": 0,
"offlineOrder": "False",
"stopLoss": 0,
"takeProfit": 0
})
headers = {
'Authorization': f'{app_id}:{access_token}',
'Content-Type': 'application/json'
}
conn.request("POST", "/api/v2/orders", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
{"s": "error", "code": -352, "message": "Please provide a valid app id.", "id": ""}
Order placing error
Trying to place market order but failing with "Please provide a valid app id.", , "id": "" but app is active. I might be wrong with the header. is the header is correct?
app_id = 'LD8XXXATGA-100'
access_token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcGk................N9o'
conn = http.client.HTTPSConnection("api.fyers.in")
payload = json.dumps({
"symbol": "NSE:ONGC-EQ",
"qty": 1,
"type": 2,
"side": 1,
"productType": "INTRADAY",
"limitPrice": 0,
"stopPrice": 0,
"validity": "DAY",
"disclosedQty": 0,
"offlineOrder": "False",
"stopLoss": 0,
"takeProfit": 0
})
headers = {
'Authorization': f'{app_id}:{access_token}',
'Content-Type': 'application/json'
}
conn.request("POST", "/api/v2/orders", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
{"s": "error", "code": -352, "message": "Please provide a valid app id.", "id": ""}
Join FYERS Community to pick others' brains on Trading/Investing