console.log(response.data); // returns { status: 'success', data: [] } //why is data empty here? how can I get the status REJECTED here???
} catch (error) { console.error('Catch Error:', error.response.data.message); //returns Insufficient stock holding or there are pending sell orders for this stock. Check the orderbook.... } }
There are only two APIs supported by Kite Connect, one is fetching the whole orderbook or fetch order history. I would suggest fetch the orderbook and check the status of the particular order using order id.
status_message
field from the order history, to know the rejection reason. I just tried, getOrderTrades, and it's working fine, with no status url encoded param addition. Can you paste here the exact code for this?async function retrieveParticularExecutedOrder(order_id){
console.log(order_id); //checking to ensure correct order_id is passed
try {
const response = await axios.get('https://api.kite.trade/orders/' + order_id + '/trades', {
headers: {
'X-Kite-Version': '3',
'Authorization': `token :` + accessToken,
},
});
console.log(response.data); // returns { status: 'success', data: [] } //why is data empty here? how can I get the status REJECTED here???
} catch (error) {
console.error('Catch Error:', error.response.data.message); //returns Insufficient stock holding or there are pending sell orders for this stock. Check the orderbook....
}
}
async function retrieveParticularExecutedOrder(order_id){
console.log(order_id); //checking to ensure correct order_id is passed
var kc = new KiteConnect({api_key: apiKey});
kc.getOrderTrades(order_id);
console.log(kc.response);
}
I would suggest fetch the orderbook and check the status of the particular order using order id.