Note that there are some explanatory texts on larger screens.

plurals
  1. POGson Syntax Exception causing Retrofit Error
    text
    copied!<p>I am in the process of connecting to a custom RESTful API using Retrofit. I have testing communicating with the device/API via Curl and with some test Java code running on a non-Android system (mac os x). The curl and java commands return the expected response.</p> <p>However, using retrofit, I am unsure if I am using an inadequate configuration in my RestAdapter (i.e. RestAdapter.Builder()) to talk to this device.</p> <p>The error I am getting appears to be that the entire json contents is not returned and only the first 47 bytes or so. I expect this is a behavior of the device I'm talking to, and am curious if this means I need to implement an Asynchronous callback as described in the Retrofit API docs. Before I do this I wanted to get feedback from some who have more experience with Retrofit.</p> <p>The error is as follows (sanitized for public consumption):</p> <pre><code>12-06 08:50:52.962 28267-1735/com.mycompany.project D/Retrofit? [ 12-06 08:50:52.972 28267: 1735 D/Retrofit ] {"OBJECT1":{"@Version":1,"OBJECTARRAY1":[ 12-06 08:50:52.972 28267-1735/com.mycompany.project D/Retrofit? &lt;--- END HTTP (46-byte body) 12-06 08:50:52.982 28267-1735/com.mycompany.project W/System.err retrofit.RetrofitError: retrofit.converter.ConversionException: com.google.gson.JsonSyntaxException: java.io.EOFException: End of input at line 1 column 47 </code></pre> <p>I am setting up the RestAdapter as such:</p> <pre><code> RestAdapter restAdapter = new RestAdapter.Builder() .setServer(serverUrl) .setClient(new OkClient(RestUtils.getHttpClient(3000, 3000, username, password))) .setRequestInterceptor(new RequestInterceptor() { @Override public void intercept(RequestFacade requestFacade) { requestFacade.addHeader("Accept", "application/json"); requestFacade.addHeader("Client-Id", "12345"); } }) .setLogLevel(RestAdapter.LogLevel.FULL) .build(); service = restAdapter.create(OBJECT1.class); </code></pre> <p>Any insight into this problem would be greatly appreciated. I understand this error is related to the java.io.EOFException, but have been unable to verify the contents I am getting returned from the device, except for the output shown above in the error. I am heavily leaning towards the async vs. sync being the issue, but am open to any recommendations.</p> <p>Cheers!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload