Retrofit: EOFException: End of input at line 1 column 1 path $

Created on 11 Aug 2016  路  3Comments  路  Source: square/retrofit

I used Retrofit 2 with OkHttpClient.
While parsing the API error repose I got error as below
Error message son which I have parsed is {"error":["The selected email is invalid."]}

Error in Android Studio is
W/System.err: java.io.EOFException: End of input at line 1 column 1 path $
W/System.err: at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1393)
W/System.err: at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:549)
W/System.err: at com.google.gson.stream.JsonReader.peek(JsonReader.java:425)
W/System.err: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:205)
W/System.err: at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:37)
W/System.err: at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:25)

Most helpful comment

This error message indicates a completely empty response, not the one you have indicated. If it's an error you should be using errorBody() to get access to the data. If this is a normal response then you should yell at your server for returning no content when content was expected. But if you cannot change the server, consider using a converter to adapt empty bodies into null using something like this: https://github.com/square/retrofit/issues/1554#issuecomment-178633697

All 3 comments

This error message indicates a completely empty response, not the one you have indicated. If it's an error you should be using errorBody() to get access to the data. If this is a normal response then you should yell at your server for returning no content when content was expected. But if you cannot change the server, consider using a converter to adapt empty bodies into null using something like this: https://github.com/square/retrofit/issues/1554#issuecomment-178633697

Alternatively, I think you can just use the Void object for the response and this error does not come up. Will get a 201 for created if thats what the call intended to do - generally in my experience 201's have no response body

@JakeWharton I am facing the same issue. But when I try the same API call on the postman. I am getting the error message. But the same doesn't seem to be true when using retrofit and handling the errorBody.

Was this page helpful?
0 / 5 - 0 ratings