如何发送不带参数的改造 2 post 调用
How to send a retrofit 2 post call with no parameters
我必须在 android 中使用改造 2 调用 api。但没有价值。当我这样做时,它表明必须至少有 1 个@field。下面是我正在使用的代码。
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 WhosebugAPI = retrofit.create(gitAPI.class);
Call<Questions[]> call = WhosebugAPI.loadQuestions();
call.execute();
在您的界面中使用 next 声明 body 值:
@Body RequestBody body
并包装 String JSON object:
RequestBody body = RequestBody.create(MediaType.parse("application/json"), (new JsonObject()).toString());
我必须在 android 中使用改造 2 调用 api。但没有价值。当我这样做时,它表明必须至少有 1 个@field。下面是我正在使用的代码。
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 WhosebugAPI = retrofit.create(gitAPI.class);
Call<Questions[]> call = WhosebugAPI.loadQuestions();
call.execute();
在您的界面中使用 next 声明 body 值:
@Body RequestBody body
并包装 String JSON object:
RequestBody body = RequestBody.create(MediaType.parse("application/json"), (new JsonObject()).toString());