TypeError when calling https order API via Python

tahseen edited November 2017 in API clients
Please help. Am trying to place place a bracket order and I am doing below as per the Kite Connect Documentation

Please note access_token and api_key is correct they are working with requests for historical data

Bracket Order payload created. 

payload = {

response = requests.post("https://api.kite.trade/orders/regular", data=payload)

throw this errorTypeError: 'set' object has no attribute '__getitem__'
  • sujith
    I think you missed adding trailing_stoploss.
    You can refer to example here.
  • tahseen
    trailing_stoploss is an optional parameter and it is mentioned also in the API Document on the website
  • sujith
    Can you give us the error message and status code, maybe that will help to narrow down the issue?
  • tahseen
    tahseen edited November 2017
    I found the reason. On your Kite Connect page you have incorrectly written how the post data is submitted via requests.post function of requests module in Python

    Default payload is JSON format. Your documentation on site is incorrect. Please correct it. It should be like this

    payload = {
    "param1" : data1,
    "param2" : data2,

    INCORRECT STYLE (Mentioned on Kite Connect Website Documentation)

    payload = {
Sign In or Register to comment.