当我在Postman中以body (x-www-form-urlencoded)的形式发布数据时,可以正常工作。但是在使用Retrofit 2.0 Android时却无法正常工作。
这段代码不起作用。我也尝试了 @FormUrlEncoded。
@Headers("Content-Type: application/x-www-form-urlencoded")
@POST("/api/jsonws/pushUserData")
Call<ResponseBody> pushData(@Body JSONObject jsonObj);
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("role","owner");
jsonObject.put("id","27001");
} catch (JSONException e) {
e.printStackTrace();
}
ApiInterface apiInterface1= ApiClient.getClientAuthentication().create(ApiInterface.class);
Call<ResponseBody> responseBodyCall = apiInterface1.pushData(jsonObject);
这段代码不起作用。我也尝试了 @FormUrlEncoded。