Placing GTT orders via API - StatusCodeError: 400, message: Invalid order params

xameeramir
xameeramir edited August 2020 in API clients
I'm trying to place a GTT order with this value:
{
type: 'single',
condition: {
exchange: 'NSE',
tradingsymbol: 'JMA',
trigger_values: [ 35.15 ],
last_price: 31
},
orders: [
{
exchange: 'NSE',
tradingsymbol: 'JMA',
transaction_type: 'SELL',
quantity: 241,
order_type: 'LIMIT',
product: 'CNC',
price: 35.15
}
]
}
However it is throwing StatusCodeError: 400 - "{\"status\":\"error\",\"message\":\"Invalid order params.\",\"data\":null,\"error_type\":\"InputException\"}"

Everything seems correct as per the doc: https://kite.trade/docs/connect/v3/gtt/#placing-triggers

What is the problem here?
Tagged:
  • rakeshr
    @xameeramir
    Order params seem to be correct. Which client are you using?
  • xameeramir
    @rakeshr I'm directly hitting the API using Node js request-promise npm package
  • Rushabh
    Any resolution to this? I am facing the same issue
  • rakeshr
    StatusCodeError: 400 - "{\"status\":\"error\",\"message\":\"Invalid order params.\",\"data\":null,\"error_type\":\"InputException\"}"
    This means, either form-encoded input parameters is sent wrong/missing or wrong Content-Type header being used. You will need to use application/x-www-form-urlencoded content-type header for the request here. Go through the documentation here.
  • Rushabh
    Rushabh edited October 2022
    Found the issue. we need to pass orders and condition in json encoded format:


    {
    type: 'single',
    condition: json.dumps({
    exchange: 'NSE',
    tradingsymbol: 'JMA',
    trigger_values: [ 35.15 ],
    last_price: 31
    }),
    orders: json.dumps([
    {
    exchange: 'NSE',
    tradingsymbol: 'JMA',
    transaction_type: 'SELL',
    quantity: 241,
    order_type: 'LIMIT',
    product: 'CNC',
    price: 35.15
    }
    ])
    }


This discussion has been closed.