Changing LIMIT ORDER to Market Order

Sushil_NSE
Hi All,
Need help with below. Once my Overall target is achieved i am trying to release my Open Orders to Market price but not able to do so as getting below error -
{"status":"error","message":"Request method not allowed","data":null,"error_type":"GeneralException"}

Followed below Document for Payload (Modify Orders)-
https://kite.trade/docs/connect/v3/orders/

Using Code as below -

/***************************** Modify Zerodha Order : Start ******************************/
// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
// Use below for Market Orders
curl_setopt($ch, CURLOPT_URL, "https://api.kite.trade/orders/regular/$current_order_id");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Kite-Version: 3',
"Authorization: token $API_KEY:$ACCESS_TOKEN"
));
// grab URL and pass it to the browser
// Modify to MARKET Orders
$data="quantity=$quantity&order_type=MARKET&validity=DAY";
echo $data;
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response=curl_exec($ch);

// close cURL resource, and free up system resources
print_r($response);
/***************************** Modify Zerodha Order : End ******************************/

Please Help!!!

-Sushil
  • Sushil_NSE
    Got it resolved. Needed to pass request type -

    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
  • sujith
    Can you let us know the order id for which you got this error? We will check and get back to you.
  • sujith
    You are not using Kite Connect PHP client?
Sign In or Register to comment.