Reputation: 407
I need make POST request with parameters "guid=1" in Body. i use Retrofit2
I try :
@POST("/api/1/model")
Call<ApiModelJson> getPostClub(@Body User body);
User Class:
public class User {
@SerializedName("guid")
String guid;
public User(String guid ) {
this.guid = guid;
}
MailActivity:
User user =new User ("1");
Call<ApiModelJson> call = service.getPostClub(user);
call.enqueue(new Callback<ApiModelJson>() {
@Override
public void onResponse(Response<ApiModelJson> response) {
}
@Override
public void onFailure(Throwable t) {
dialog.dismiss();
}
How make this request?
Upvotes: 0
Views: 2541
Reputation: 26084
With code below, you can make the request synchronously:
ApiModelJson responseBody = call.execute();
If you want it to be asynchronous:
call.enqueue(new Callback<ApiModelJson>() {
@Override
public void onResponse(Response<ApiModelJson> response, Retrofit retrofit) {
}
@Override
public void onFailure(Throwable t) {
}
});
Upvotes: 0