I use Retrofit2, I want to send parameters to the POST server.
public interface ServerApi { @GET("Singleton") Call<String> getJSON(); @POST("Singleton") Call<String> senDDudes(@Query("author") String author); } I use this interface to send data. When entering the server, the data is received in the POST format, and then returned in the JSON format.
Retrofit rt; rt=new Retrofit.Builder().baseUrl("http://10.0.2.2/").addConverterFactory(ScalarsConverterFactory.create()).addConverterFactory(GsonConverterFactory.create()).build(); ServerApi sapi=rt.create(ServerApi.class); Call<String> msg=sapi.senDDudes("Dude","bude"); msg.enqueue(new Callback<String>() { @Override public void onResponse(Call<String> call, Response<String> response) { System.out.println(response.body().toString()); } @Override public void onFailure(Call<String> call, Throwable t) { System.out.println(t.toString()); } }); The problem is that the data in the form of POST does not come to the server. There is a refund, but there is no reception. I check with echo $ _POST ['author'] on the server itself.
BUT if I use the @GET annotation instead of the @POST annotation, and output echo $ _GET ['author'] accordingly, the data is output.
In Retrofit, I'm new, so please consider this.