setResultLimit with limit 1 throws an Exception in Gson parser
Way to reproduce: ApiClient client = new RestApiClient().withLoggingEnabled().withCredentials( "userid", "apikey" ); Account.Service service = Account.service( client ); service.setResultLimit( new ResultLimit( 1,1 ) ); service.getHardware();
In result the JavaClient makes the following request:
https://api.softlayer.com/rest/v3.1/SoftLayer_Account/Hardware.json?resultLimit=1,1
And SL API returns a single Json object instead of array of Json objects, but Gson is expecting list of Json objects and we are facing with the following exception:
Exception in thread "main" com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $
I think you need a fix on SL Rest API side :)
Thanks in advance.
In this case, we cannot change the REST API response here even though it is obviously unintuitive to have something that says it returns an array return a single object. I will have to make a Gson custom deserializer to handle this.
This has been fixed in master. I will leave this open until we release the next version to maven with this fix in it.
Released 0.2.3 which should address this issue.