-1

I want to get the content of request object after it serializes passed object. I want to uderstand how retrofit serilizes my object.

@POST("/RegisterNewDevice")
public void registerDevice (@Body Device device, 
    retrofit.Callback<ResultBooleanResponse> callback);

How retrofit will represent my Device object? Let's say it is defined as follows:

public class Device {
    private int id;
    private String deviceName;

    //... constructors, getters and setters ...//

}

Because of https connection used for my services I cannot intercept it easily.

shadox
  • 3,238
  • 4
  • 24
  • 38
  • If you've included Gson in your dependency, Retrofit will use that to serialize your POJO. – Udit Mukherjee Aug 31 '15 at 10:11
  • Ok, but will it go as is into the body of request? Based on that I'm building a service and it does not work. The same request made with external tool, works as expected. – shadox Aug 31 '15 at 10:16
  • I suggest you go through this [answer](http://stackoverflow.com/questions/21398598/how-to-post-raw-whole-json-in-the-body-of-a-retrofit-request) – Udit Mukherjee Aug 31 '15 at 10:19

1 Answers1

0

I think the @SerializedName should help you. Remember you can only use request body when your request is POST, PUT type.

public class SampleRequestBody {
    @SerializedName("param1")
    final String param1;

    @SerializedName("param2")
    final int param2;

    // public constructer
}

If your request is GET, DELETE, .. type, so you should use @Query

@POST("/abc/def")
void methoName(@Query("param_name") String param, Callback<type> callback);
Nhat Dinh
  • 3,378
  • 4
  • 35
  • 51
  • I need content of the body of HTTP/HTTPS request. I want to see how exactly it serializes my information. If there is a dot, if there is a bracket ... and so on. The problem actually was with https connections so I had to write a small servlet to se exactly the content but from retrofit only I did not figured out how to do that. – shadox Sep 03 '15 at 08:02