0

I was sending a String using GET in Retrofit and it worked well in my PHP server file.

e.g.

@GET("add.php")
Call<Void> getData(@Query("value") String value);

and this could be retrieved using $_GET['value']. This string was a JSON string converted from an object, say of class Survey.

Now that this string has become very long, I decided to use POST instead of GET otherwise I get a URI too long error.

My new code is this:

@POST("add.php")
Call<Void> getData(@Body Survey survey);

My query is, how can I retrieve this data in my PHP file now (since I am not mentioning the value parameter anymore).

Anindya Dutta
  • 1,972
  • 2
  • 18
  • 33

1 Answers1

0

You could add a header to the call like so

@POST("add.php")
Call<Void> getData(@Body Survey survey,
                   @Header("value") String value);

And account for the header in the PHP code

MacLean Sochor
  • 435
  • 5
  • 14