cancel order giving 5202 invalid request
Closed this issue · 2 comments
Hi team ,
When I try to cancel order using php web api . I am getting Invalid request error.
same order is placed by using php web api, same order modified using php web api.
but when I try to cancel the same order using php web api I am getting error.
Here is my response :
{"stat": "Not_Ok","stCode":5202,"errMsg": "Error: Invalid Request","tid":"server4_1258509"}
my cancel order request details :
req url : https://gw-napi.kotaksecurities.com/Orders/2.0/quick/order/cancel?sId=server4
order no : 241015000933494
Note: all values I am using dynamic . I mean server , access token , login token, sid ... etc. when I got response from web api I am storing in my local system and in next request I am using those values so there is no static values I am using.
I just pass the order no to cancel the pending orders like,
function cancelBROrder(orderNo) {
const url = "https://mlhsi.kotaksecurities.com/quick/order/bo/exit";
const params = {
"sId": authorizationServer,
"requestId": "1"
};
const jData = {
"on": `${orderNo}` // Ensuring the sym is wrapped in double quotes
};
// const jData = {
// "on": `${orderNo}`, // Ensuring the sym is wrapped in double quotes
// "am":"YES",
// "ts":"FINNIFTY2461822600CE"
// };
const data = {
"jData": JSON.stringify(jData)
};
// console.log(data)
const queryString = new URLSearchParams(params).toString();
const requestUrl = `${url}?${queryString}`;
fetch(requestUrl, {
method: 'POST',
headers: headers,
body: new URLSearchParams(data)
})
.then(response => response.json())
.then(data => {
console.log('Order Canceled:', data);
})
.catch((error) => {
console.error('Error:', error);
});
}
function cancelOrder(orderNo) {
const url = "https://mlhsi.kotaksecurities.com/quick/order/cancel";
const params = {
"sId": authorizationServer,
"requestId": "1"
};
const jData = {
"on": `${orderNo}` // Ensuring the sym is wrapped in double quotes
};
// const jData = {
// "on": `${orderNo}`, // Ensuring the sym is wrapped in double quotes
// "am":"YES",
// "ts":"FINNIFTY2461822600CE"
// };
const data = {
"jData": JSON.stringify(jData)
};
// console.log(data)
const queryString = new URLSearchParams(params).toString();
const requestUrl = `${url}?${queryString}`;
fetch(requestUrl, {
method: 'POST',
headers: headers,
body: new URLSearchParams(data)
})
.then(response => response.json())
.then(data => {
console.log('Order Canceled:', data);
})
.catch((error) => {
console.error('Error:', error);
});
}
I fetch the pending orders and pass the order no like cancelBROrder(order.nOrdNo);
cancelOrder(order.nOrdNo);
Note that you can not place a Bracket Order via neo api its not available but you can do that on web api.
Were "sId": authorizationServer,
is the server name and headers: headers,
must contain the user cookie to make the request.
I find that order no key I am passing as wrong instead of "on" , I am passing as "no".