I was wondering how could I go about sending a custom object to my API using retrofit, something like this:
@POST("SubmitGeneralRequest")
Call<ResponseBody> sendGeneralRequest(@Body GeneralRequestRetrofit simpleRequest);
For the custom object is something like this:
public class GeneralRequestRetrofit {
private String loginDomain;
private Map<String, String> authParams;
private String requestCode;
private Resource resource;
//Resource is a class that be shared with server-side and client-side (Android)
public GeneralRequestRetrofit() {
}
public String getLoginDomain() {
return this.loginDomain;
}
public void setLoginDomain(String loginDomain) {
this.loginDomain = loginDomain;
}
public Map<String, String> getAuthParams() {
return this.authParams;
}
public void setAuthParams(Map<String, String> authParams) {
this.authParams = authParams;
}
public String getRequestCode() {
return this.requestCode;
}
public void setRequestCode(String requestCode) {
this.requestCode = requestCode;
}
public Resource getResource() {
return this.resource;
}
public void setResource(Resource resource) {
this.resource = resource;
}
}
It seems that the GSON Converter cannot convert the class "Resource" that is self-defined by the server-side. I Google for a long time, some people point out that using deserializer. However, I still have no clues how to start with.
For more information: "Resource" is a class in the .jar file that be imported to android studio.
Anyone can give me some advice?