• Developers Bugs Fixed
  • [Bug] Error while creating ApiContext with the Java SDK

Hi All,

Ever since I updated the version of the bunq sdk_java dependency (1.10.16->1.13.1, due to connection issues https://github.com/bunq/tinker_java/issues/16). I get the following error " BEGIN_OBJECT but was BEGIN_ARRAY" when invoking the ApiContext.create method. For some reason this error only occurs with my production api key but not with any sandbox api key. I tried creating a new production api key but without success. I was hoping that someone could help me with this.

Stacktrace:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at path $.director_alias
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:226)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
at com.google.gson.Gson.fromJson(Gson.java:927)
at com.google.gson.Gson.fromJson(Gson.java:994)
at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162)
at com.bunq.sdk.json.SessionServerAdapter.deserialize(SessionServerAdapter.java:57)
at com.bunq.sdk.json.SessionServerAdapter.deserialize(SessionServerAdapter.java:23)
at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
at com.google.gson.Gson.fromJson(Gson.java:927)
at com.google.gson.Gson.fromJson(Gson.java:994)
at com.google.gson.Gson.fromJson(Gson.java:967)
at com.bunq.sdk.model.core.BunqModel.fromJsonArrayNested(BunqModel.java:69)
at com.bunq.sdk.model.core.SessionServer.create(SessionServer.java:78)
at com.bunq.sdk.context.ApiContext.initializeSession(ApiContext.java:272)
at com.bunq.sdk.context.ApiContext.initialize(ApiContext.java:225)
at com.bunq.sdk.context.ApiContext.create(ApiContext.java:140)
at com.bunq.sdk.context.ApiContext.create(ApiContext.java:122)
at com.bunq.sdk.context.ApiContext.create(ApiContext.java:114)

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at path $.director_alias
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:226)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
at com.google.gson.Gson.fromJson(Gson.java:927)
at com.google.gson.Gson.fromJson(Gson.java:994)
at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162)
at com.bunq.sdk.json.SessionServerAdapter.deserialize(SessionServerAdapter.java:57)
at com.bunq.sdk.json.SessionServerAdapter.deserialize(SessionServerAdapter.java:23)
at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
at com.google.gson.Gson.fromJson(Gson.java:927)
at com.google.gson.Gson.fromJson(Gson.java:994)
at com.google.gson.Gson.fromJson(Gson.java:967)
at com.bunq.sdk.model.core.BunqModel.fromJsonArrayNested(BunqModel.java:69)
at com.bunq.sdk.model.core.SessionServer.create(SessionServer.java:78)
at com.bunq.sdk.context.ApiContext.initializeSession(ApiContext.java:272)
at com.bunq.sdk.context.ApiContext.initialize(ApiContext.java:225)
at com.bunq.sdk.context.ApiContext.create(ApiContext.java:140)
at com.bunq.sdk.context.ApiContext.create(ApiContext.java:122)
at com.bunq.sdk.context.ApiContext.create(ApiContext.java:114)

    @BLACKBEAR-B-V-Red-Owl#160481 Hello!

    Thanks for reporting.

    This is a known issue. I've forwarded this issue yesterday to the product owner.

      Bastiaan changed the title to [Bug] Error while creating ApiContext with the Java SDK.

        @Bastiaan Do you mean that the documentation is not correct? The documentation clearly lists it as an object.
        For reference, we get the same error in our application and we directly call the API without any SDK.

          4 days later

          Hey everyone! 👋

          The issue won't be there tomorrow morning. You don't need to do anything on your side.

            @Nils-indigo @Cointopay-International-B-V-Aquamarine-Cheetah#160756 @Frank-Indigo-Turtle#160490 @BLACKBEAR-B-V-Red-Owl The fix is live. 🎊

              Hey, thanks for the quick responses and the quick solution, the error above is resolved. However I now get a
              com.bunq.sdk.exception.BunqException: Response verification failed Exception when connecting with the API Key. Do you know what could be a reason for this?

                @BLACKBEAR-B-V-Red-Owl#161844 What SDK version are you using?

                  @BLACKBEAR-B-V-Red-Owl#161915 We cannot reproduce this problem (we've tried both sandbox and production). The issue must lie in something else.

                    Write a Reply...