When I send a request that results in a response with status other than HTTP_OK (200), the API server is currently replying in a format that is not JSON (probably HTML, due to some application firewall at Gerencianet's cloud).
When the response arrives, an exception is being thrown at line 59 of at br/com/gerencianet/gnsdk/Request.java with the following stacktrace:
org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1] at org.json.JSONTokener.syntaxError(JSONTokener.java:451) at org.json.JSONObject.<init>(JSONObject.java:195) **at br.com.gerencianet.gnsdk.Request.send(Request.java:59)** at br.com.gerencianet.gnsdk.APIRequest.send(APIRequest.java:59) at br.com.gerencianet.gnsdk.Endpoints.kernelCall(Endpoints.java:80) at br.com.gerencianet.gnsdk.Endpoints.call(Endpoints.java:61)
The code is assuming the response will always be in JSON format, but it does not specify that requirement in the Accept header of the request.
To fix the issue, this class must include a header "Accept: application/json" (provided that the server honors it).