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
How to Get the Value of a Listview Item Which Is Clicked in Android
How to Resize the Avd Emulator Window in Android Studio
Remove Old Fragment from Fragment Manager
How to Get the Timezone Offset in Gmt(Like Gmt+7:00) from Android Device
Recyclerview Slow Scrolling Performance and Lag/Halt Sometime While Scrolling
Sending Files Using Post With Httpurlconnection
How to Set Button Click Effect in Android
How to Make a New Line or Tab in <String> Xml (Eclipse/Android)
Open External Links in the Browser With Android Webview
How to Avoid Keyboard Pushing Layout Up on Android React-Native
Getting Simple Json Object Response Using Retrofit Library
Making Voice Calls from Android Phone Connected to Linux
Check If Json Object Contains Specific Value
Sharing Link on Whatsapp from Mobile Website (Not Application) For Android