Facing error in REST API calls

Error : {“errorCode”:“BAD_REQUEST_ERROR”,“httpStatus”:“BAD_REQUEST”,“internalErrorCode”:“RS-9005”,“internalErrorMessage”:" todo mandatory fields "}

Code: CURLOPT_POSTFIELDS => json_encode([
‘dhanClientId’ => ‘1100532878’,
‘correlationId’ => ‘VK1110’,
‘transactionType’ => ‘BUY’,
‘exchangeSegment’ => ‘NSE_FNO’,
‘productType’ => ‘INTRADAY’,
‘orderType’ => ‘MARKET’,
‘validity’ => ‘DAY’,
‘tradingSymbol’ => ‘BANKNIFTY 28 DEC 49400 PUT’,
‘securityId’ => ‘35005’,
‘quantity’ => 50,
‘disclosedQuantity’ => 0,
‘price’ => 18.0,
‘triggerPrice’ => 0,
‘afterMarketOrder’ => null,
‘amoTime’ => ‘OPEN’,
‘boProfitValue’ => 1000,
‘boStopLossValue’ => 100,
‘drvExpiryDate’ => ‘28-12-23 14:30’,
‘drvOptionType’ => ‘PUT’,
‘drvStrikePrice’ => 49400
]),

if any mistake done from my side then pls provide me a sample code for json data only for next week NIFTY CE/PE option sample running json data…

Hello @9915588558

BankNifty Lot size is currently ‘15’. The quantity needs to be in the multiple of 15 only. Also, there are some other mistakes, so kindly refer documentation: Orders - DhanHQ Ver 1.0 / API Document
The Order JSON for 1 lot would be:

Code: CURLOPT_POSTFIELDS => json_encode([
‘dhanClientId’ => ‘1100532878’,
‘correlationId’ => ‘VK1110’,
‘transactionType’ => ‘BUY’,
‘exchangeSegment’ => ‘NSE_FNO’,
‘productType’ => ‘INTRADAY’,
‘orderType’ => ‘LIMIT’,
‘validity’ => ‘DAY’,
‘tradingSymbol’ => ‘BANKNIFTY 28 DEC 49400 PUT’,
‘securityId’ => ‘35005’,
‘quantity’ => 15,
‘disclosedQuantity’ => 0,
‘price’ => 18.0,
‘triggerPrice’ => 0,
‘afterMarketOrder’ => FALSE,
‘amoTime’ => ‘OPEN’,
‘boProfitValue’ => 0,
‘boStopLossValue’ => 0,
‘drvExpiryDate’ => ‘28-12-23 14:30’,
‘drvOptionType’ => ‘PUT’,
‘drvStrikePrice’ => 49400
]),

is it compulsory to mention price if order type is Market

just try not for testing and get this message

{“errorCode”:“BAD_REQUEST_ERROR”,“httpStatus”:“BAD_REQUEST”,“internalErrorCode”:“RS-9005”,“internalErrorMessage”:“Market is Closed! Want to place an offline order?”}

Hello @9915588558

Price does not needs to be mentioned, if the order type is Market. It simply needs to be 0 in that scenario.

For the error, you must have placed the order after market (which is mentioned on Error Message). If you want to place after market order, you can do the same by keeping afterMarketOrder flag as TRUE.