Android 如何在没有参数的情况下发送改装2 post呼叫
我必须在android中使用改型2调用api。但是没有价值。当我这样做的时候,它表明必须至少有1个@field。下面是我正在使用的代码Android 如何在没有参数的情况下发送改装2 post呼叫,android,post,retrofit2,Android,Post,Retrofit2,我必须在android中使用改型2调用api。但是没有价值。当我这样做的时候,它表明必须至少有1个@field。下面是我正在使用的代码 public interface gitAPI { @FormUrlEncoded @POST("/MembersWS.svc/GetMemberAvailability/MBR0011581") Call<Questions[]> loadQuestions(); } Retrofit retrofit = ne
public interface gitAPI {
@FormUrlEncoded
@POST("/MembersWS.svc/GetMemberAvailability/MBR0011581")
Call<Questions[]> loadQuestions();
}
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://192.168.1.99:82")
.addConverterFactory(GsonConverterFactory.create())
.build();
// prepare call in Retrofit 2.0
gitAPI stackOverflowAPI = retrofit.create(gitAPI.class);
Call<Questions[]> call = stackOverflowAPI.loadQuestions();
call.execute();
公共接口gitAPI{
@FormUrlEncoded
@POST(“/MembersWS.svc/GetMemberAvailability/MBR0011581”)
调用loadQuestions();
}
改装改装=新改装.Builder()
.baseUrl(“http://192.168.1.99:82")
.addConverterFactory(GsonConverterFactory.create())
.build();
//准备呼叫改装2.0
gitAPI stackOverflowAPI=reformation.create(gitAPI.class);
Call Call=stackOverflowAPI.loadQuestions();
call.execute();
在与next的界面中声明正文值:
@Body RequestBody Body
和包装字符串JSON对象:
RequestBody body = RequestBody.create(MediaType.parse("application/json"), (new JsonObject()).toString());
尝试删除@FormUrlEncodedannotation@SreekanthKarumanaghatsry,那是很久以前的事了,我现在不使用Java。也许链接到我的另一个问题与相同的答案将有助于你