【发布时间】:2020-01-24 21:25:29
【问题描述】:
我正在尝试在 vscode 中使用 REST 客户端进行 POST Authenticate,但它不接受我的表单数据。这是邮递员的 http 代码,它似乎与 https://marketplace.visualstudio.com/items?itemName=humao.rest-client 上的规范匹配,但我不明白为什么它在从 vscode 提交时不喜欢我的凭据。非常感谢任何帮助或指示。
Request:
POST /myservicestack/authenticate/credentials HTTP/1.1
Host: services.mydomain.com
Accept: application/json
cache-control: no-cache
Postman-Token: cdax7d61-8d8b-4f3q-b45v-74a240f33693
Content-Disposition: form-data; name="UserName"
myemail@address.com
Content-Disposition: form-data; name="Password"
My Password!
Content-Disposition: form-data; name="RememberMe"
true
------WebKitFormBoundary7MA4YWxkTrZu0gW--
Response:
{
"responseStatus": {
"errorCode": "ValidationException",
"message": "Validation failed: \r\n -- 'User Name' should not be empty.\r\n --
'Password' should not be empty.",
"errors": [
{
"errorCode": "NotEmpty",
"fieldName": "UserName",
"message": "'User Name' should not be empty.",
"meta": {
"PropertyName": "User Name"
}
},
{
"errorCode": "NotEmpty",
"fieldName": "Password",
"message": "'Password' should not be empty.",
"meta": {
"PropertyName": "Password"
}
}
]
}
}
【问题讨论】:
-
服务器期望数据的格式是什么?是 JSON 还是多部分表单?
-
我检查了邮递员,那篇文章是错误的。我从 Headers 中删除,但邮递员仍然得到 200。从我上面的 sn-p 中删除。