scripconsent order parameter missing in Java library. Order placement fails with Null
-
The scripconsent=yes parameter cannot be set with smartconnect smartapi-java-2.2.6.jar which is the latest. I get an error as below from SmartConnect API:
2026-02-18 13:27:55.094 ERROR [ Transaction-0] com.angelbroking.smartapi.SmartConnect : [316] JSONObject["data"] is not a JSONObject (class org.json.JSONObject$Null : null).
My order placement fails. Upon investigation I found I get error only for certain stocks like stocks of BSE shares which are cautionary. I dont get this when i place orders for stocks like HDFC or SILVERMIC.
I cant override or cannot do much. I have done all my code with your JAVA APIs, and now I am stuck in this blocker. Please update the JAVA API, if smartconnect API added any changes so that your API documentation is in sync with your Java implementation.
-
@sugagenius git clone the Github repository https://github.com/angel-one/smartapi-java. Update Order.java model https://github.com/angel-one/smartapi-java/blob/main/src/main/java/com/angelbroking/smartapi/models/Order.java#L128 by adding scripconsent=yes in the end and compile into new jar file.
-
@algo_trading_50 That defeats the purpose of using an SDK JAR released. It adds additional burden for me to compile and build such things. I should be able to use the jar straight away from Angel one. I have bigger things to do.
-
@sugagenius In fact I wasted a lot of effort only to find this as the root cause. The APIs failed silently with Null pointer exception. It is from my great effort and experience i were able to find something out of nowhere.
-
@sugagenius I can understand your frustration. To build it yourself.
git clone https://github.com/angel-one/smartapi-java.git cd smartapi-java # Fix Order.Java mvn clean package -DskipTestsCompiled jar file will be in target folder.
-
Even after replacing the class with the missing parameter, I still a null pointer error.
-
I changed the SmartConnect.java.
Just before sending the order in placeOrder() method, I added this line "params.put("scripconsent", "yes")"But you have mentioned Order.java as well. I will rectify that as well. I see that Order.java is used for serialization/deserilization. Let me fix and retry tomorrow. I can test only when market is live. Is there any way to test such things when market is off ?
-
Even if I ignore the fix for Order.java, my fix on SmartConnect.java should have got my order submitted at least to the exchange. But that didnt happen. How sending the post request is affected by not modifying Order.java. Order.java is used for receiving the data. I see no Error while sending the postRequest or while receiving the postRequest inside the API JAR. I see only this after receiving the response. Basically, the request is not even reaching the server for such scripts I think. That is the reason we get null. but this issue is not seen in the SDK logs.
-
I fixed the issue by changing 3 files in the JAVA SDK code and rebuilding it. I doubt fixing Order.java alone would resolve this.
I fixed SmartConnect.java -> params.put("scripconsent", "yes");
Order.java ->
@SerializedName("scripconsent")
public String scripconsentand OrderParams.java ->
public String scripconsentNow I can see AMO orders reaching Angel One :). Huge relief. Will re-check on Monday once the exchanges are online just to be sure.
-
@sugagenius Cheers to your persistence. :) Once done with all modifications, please make sure to send a pull request to the github repo so other algo traders can also be benefited.