This question may have been asked before but no it was not definitively answered. How exactly does one post raw whole JSON inside the body of a Retrofit request?
See
API Call
@Headers("Content-Type: application/json")
@POST("/set_data")
Call setPreferences(@Body RequestData request);
Note: Use GSON library of Retrofit
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class RequestData {
@SerializedName("access_token")
@Expose
private String accessToken;
@SerializedName("data")
@Expose
private Data data;
// The above 'Data' is another similar class to add inner JSON objects. JSONObject within a JSONObject.
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
public void setData(Data data) {
this.data = data;
}
}
I guess that will help, rest all integration you might already have had and we don't need anything fancy to use above code snippet. It's working perfectly for me.