带有保证请求的问题的问题“ valo_error.missing&quot”
我正在尝试通过REST保证的请求传递请求主体参数,但是它返回我非常令人沮丧,我正在尝试使用JSON格式(例如JSON格式)尝试不同的方式,但工作也始终同样的错误。 错误消息 value_error.missing 对于所有身体参数。
value_error.missing
{
"detail": [
{
"loc": [
"body",
"username"
],
"msg": "field required",
"type": "value_error.missing"
},
{
"loc": [
"body",
"password"
],
"msg": "field required",
"type": "value_error.missing"
}
]
}
测试代码:
public Response login(String username, String password, String proxy) {
//String user = "{\"username\":\"" + username + "\",\"password\":\"" + password + "\",\"proxy\":\"" + proxy + "\"}";
Map<String, String> user = new HashMap<>();
user.put("username", username);
user.put("password", password);
user.put("proxy", proxy);
Response response = given()
.headers(httpHeaderManager())
.body(user)
.spec(urlUser)
.post("/auth/login")
.then()
.extract().response()
return response;
}
I am trying to pass request body parameters in rest assured request, but it returns me with is very frustrating I am trying different ways I try with String like JSON format but is not working also always same error.
Error message value_error.missing for all body parameters.
value_error.missing
{
"detail": [
{
"loc": [
"body",
"username"
],
"msg": "field required",
"type": "value_error.missing"
},
{
"loc": [
"body",
"password"
],
"msg": "field required",
"type": "value_error.missing"
}
]
}
The test code:
public Response login(String username, String password, String proxy) {
//String user = "{\"username\":\"" + username + "\",\"password\":\"" + password + "\",\"proxy\":\"" + proxy + "\"}";
Map<String, String> user = new HashMap<>();
user.put("username", username);
user.put("password", password);
user.put("proxy", proxy);
Response response = given()
.headers(httpHeaderManager())
.body(user)
.spec(urlUser)
.post("/auth/login")
.then()
.extract().response()
return response;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该起作用
This should work