Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    scripconsent order parameter missing in Java library. Order placement fails with Null

    Java SDK
    2
    10
    23
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      sugagenius last edited by

      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.

      A 1 Reply Last reply Reply Quote 1
      • A
        algo_trading_50 @sugagenius last edited by

        @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.

        S 1 Reply Last reply Reply Quote 0
        • S
          sugagenius @algo_trading_50 last edited by

          @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.

          S 1 Reply Last reply Reply Quote 0
          • S
            sugagenius @sugagenius last edited by

            @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.

            A 1 Reply Last reply Reply Quote 0
            • A
              algo_trading_50 @sugagenius last edited by algo_trading_50

              @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 -DskipTests
              

              Compiled jar file will be in target folder.

              1 Reply Last reply Reply Quote 0
              • S
                sugagenius last edited by

                Even after replacing the class with the missing parameter, I still a null pointer error.

                1 Reply Last reply Reply Quote 0
                • S
                  sugagenius last edited by

                  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 ?

                  1 Reply Last reply Reply Quote 0
                  • S
                    sugagenius last edited by

                    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.

                    1 Reply Last reply Reply Quote 0
                    • S
                      sugagenius last edited by

                      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 scripconsent

                      and OrderParams.java ->
                      public String scripconsent

                      Now I can see AMO orders reaching Angel One :). Huge relief. Will re-check on Monday once the exchanges are online just to be sure.

                      A 1 Reply Last reply Reply Quote 1
                      • A
                        algo_trading_50 @sugagenius last edited by

                        @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.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post