(Resolved) Option API order placement not working

Hello Team,
I am working on a customized (light weight) GUI application from Where I can trade F&O with some predefined scripts. Just for reference, GUI will look below:

On a button click, when i am calling option order place API, I am getting below error:

"internalErrorMessage":"JSON parse error: Cannot coerce empty String (\"\") to co.dhan.api.model.enums.AmoTimevalue (but could if coercion was enabled usingCoercionConfig); nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot coerce empty String (\"\") to co.dhan.api.model.enums.AmoTimevalue (but could if coercion was enabled usingCoercionConfig)\n at [Source: (PushbackInputStream); line: 1, column: 359] (through reference chain: co.dhan.api.model.OrderRequest[\"amoTime\"])"}

My order data is as below:
Dhan: Placing Order: {'dhanClientId': <confidential>, 'correlationId':<confidential>, 'transactionType': 'SELL', 'exchangeSegment': 'NSE_FNO', 'productType': 'MARGIN', 'orderType': 'MARKET', 'validity': 'DAY', 'tradingSymbol': 'NIFTY25JAN2317850CE', 'securityId': '55888', 'quantity': 50, 'disclosedQuantity': 50, 'price': 0, 'triggerPrice': 0, 'afterMarketOrder': 'false', 'amoTime': '', 'boProfitValue': '', 'boStopLossValue': '', 'drvExpiryDate': '2023-01-25', 'drvOptionType': 'CALL', 'drvStrikePrice': -1}

Can you let me know why I am getting error , though I am sending string for dhanClientId?
I am following: Orders - DhanHQ Ver 1.0 / API Document

[Fixed]
Below combination works.

"afterMarketOrder": 'false',
"amoTime":"OPEN",

hi @sadebd - request to check and validate on post requests for orders here: Dhan API

1 Like

Thanks Pravin, I have fixed that error, Now I am getting:
"internalErrorMessage":"JSON parse error: Cannot coerce empty String (\"\") to co.dhan.api.model.enums.AmoTimevalue (but could if coercion was enabled usingCoercionConfig); nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot coerce empty String (\"\") to co.dhan.api.model.enums.AmoTimevalue (but could if coercion was enabled usingCoercionConfig)\n at [Source: (PushbackInputStream); line: 1, column: 359] (through reference chain: co.dhan.api.model.OrderRequest[\"amoTime\"])"}

Anyway, thanks for that link. Let me check that

Hey @sadebd

Do let us know if you are still facing the error. It will be helpful if you can share both the request and response structure together.

Also, you can always reach out to @Dhan_Help at help@dhan.co.

Hi Hardik,
I have fixed the issue.
Dhan API always expect some value passed in “amoTime”. Below settings worked for me:

"afterMarketOrder": 'false',
"amoTime":"OPEN",

Regards,
Sayantani

Hi,

i am getting following error details after adding above mentioned 2 keys.
{
“errorCode”: “BAD_REQUEST_ERROR”,
“httpStatus”: “BAD_REQUEST”,
“internalErrorCode”: “RS-9005”,
“internalErrorMessage”: " todo mandatory fields "
}
can you please help.

Hello @AK-algo

Welcome to Dhan Community!

Can you send the entire JSON as reference here? The error should not be because of the above two mentioned keys.

Hi Hardik

I found the fix and this issue is resolved.

2 Likes