Retrofit:Getting Error ** End of Input At Line 1 Column 1**

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

You only get that error when something is wrong with your json response, Check again to make sure both the error response and correct response are well formatted.

Enter wrong credentials using postman and see what the output looks like.

Retrofit : Getting error ** End of input at line 1 column 1**

Instead of using

@POST("index.php")

please try to use

@POST("/index.php")

and post as a

Call<LoginResponse> getHome(@Body YourBodyPojo pojo);

surely this will help you.

Retrofit2 error java.io.EOFException: End of input at line 1 column 1

just return void instead, if the body is empty

@PATCH("alerts/{alert_id}/accept") Call<Void> accept_invited_alerts(@Header("X-Api-Token") String api_token, @Path("alert_id") int alert_id);

for retrofit with Rx java you can use something like this

@PATCH("alerts/{alert_id}/accept") Observable<Response<Void>> accept_invited_alerts(@Header("X-Api-Token") String api_token, @Path("alert_id") int alert_id);

EDIT: For kotlin

@PATCH("alerts/{alert_id}/accept")
fun accept_invited_alerts(@Header("X-Api-Token") api_token: String, @Path("alert_id") alert_id: Int): Call<Unit>

and

@PATCH("alerts/{alert_id}/accept")
fun accept_invited_alerts(@Header("X-Api-Token") api_token: String, @Path("alert_id") alert_id: Int): Observable<Response<Unit>>

java.io.EOFException: End of input at line 1 column 1 path $ in Android retrofit

I have found the solution, you need to post each parameters in the form as follows, not in a wrapper class.

@FormUrlEncoded

@POST("/ifapi.php")

Call<TransactionResponse> loadData(@Field("app_id") String app_id, @Field("install_id") String install_id, @Field("useragent") String useragent, @Field("ip") String ip, @Field("mccmnc") String mccmnc, @Field("action") String action );

And for main Activity Part.

OkHttpClient httpClient = new OkHttpClient.Builder().build();
Gson gson = new GsonBuilder()
.setLenient()
.create();
Retrofit retrofit = new Retrofit.Builder().addConverterFactory(GsonConverterFactory.create(gson)).baseUrl(RestAPI.BASE_URL).client(httpClient).build();

RestAPI service = retrofit.create(RestAPI.class);
Call<TransactionResponse> meResponse = service.loadData("1", getUUID(), getUserAgent(), getIPAddress(), "20404", "start");

Hope this will resolve your issues, Regards.



Related Topics



Leave a reply



Submit