<分区>
当我在 body (x-www-form-urlencoded) 中发布数据时,它在 Postman 中工作正常。但是使用 Retrofit 2.0 Android 它不起作用。
@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。