这是返回报错信息:
"status":400
,"error":"Bad Request"
,"message":"Required String parameter
'userName' is not present"
,"path":"/login"
我的代码:
User_info login=new User_info("17375121795","a4721874");
gson=new Gson();
String user_info=gson.toJson(login);
MediaType login_type=MediaType.parse("application/json; charset=utf-8");
body=RequestBody.create(user_info,login_type);
request=new Request.Builder()
.url(BASE_URL+"/login")
.post(body)
.build();
task=client.newCall(request);
task.enqueue(new Callback() {
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
Log.d("result",e.toString());
}
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
Log.d("Success",response.body().string());
}
});
你的接口文档呢?你得按接口文档的说明写吧。
先用postMan进行模拟请求,测试过了,再去写代码.