Curl Publisher example

nisarg001
I have been trying basket orders with below curl example:
curl -H "Content-Type: application/json" -H "X-Kite-Version: 3" -H "Authorization: token XXX:YYY" --data "[{"variety":"regular", "tradingsymbol":"INFY", "exchange":"NSE", "transaction_type":"BUY", "order_type":"MARKET", "quantity":"10", "readonly":false}]" https://kite.zerodha.com/connect/basket

But getting error:
{"status":"error","message":"Invalid orders payload.","data":null,"error_type":"InputException"}

Does anyone have an example of how to use curl for basket orders?
Tagged:
  • nisarg001
    I also tried replacing quality to 10 instead of "10" and changed the quotes to ' ' from " " . But the same error.
  • sujith
    @nisarg001,
    It is a form request. You seem to be sending a JSON request.
  • sujith
    You seem to have missed the variety also, it is variety=regular
  • nisarg001
    Thanks Sujith for the prompt response. I have variety included in JSON payload.

    I tried form request, but still same response:

    curl -X POST -H "X-Kite-Version: 3" -H "Authorization: token XXX:YYY" -d "variety=regular&tradingsymbol=INFY&exchange=NSE&transaction_type=BUY&order_type=MARKET&quantity=10&readonly=false" https://kite.zerodha.com/connect/basket
    {"status":"error","message":"Invalid orders payload.","data":null,"error_type":"InputException"}

    Maybe I'm missing something minor.
  • sujith
    You need to send this header application/x-www-form-urlencoded
  • nisarg001
    Tried with the suggested header, but the same error.

    curl -H "Content-Type: application/x-www-form-urlencoded" -H "X-Kite-Version: 3" -H "Authorization: token XXX:YYY" -d 'variety=regular&tradingsymbol=INFY&exchange=NSE&transaction_type=BUY&order_type=MARKET&quantity=10&readonly=false' https://kite.zerodha.com/connect/basket

    curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -H "X-Kite-Version: 3" -H "Authorization: token XXX:YYY" -d "variety%3Dregular%26tradingsymbol%3DINFY%26exchange%3DNSE%26transaction_type%3DBUY%26order_type%3DMARKET%26quantity%3D10%26readonly%3Dfalse" https://kite.zerodha.com/connect/basket
  • Vivek
    Basket is not meant to be curled because it maintains a cookie session and shows the basket. So testing with curl won't do much.
  • nisarg001
    I see, thanks for clarification.
This discussion has been closed.