REST客户端扩展未在VSCode中发送表单数据

时间:2020-01-24 21:25:29

标签: rest visual-studio-code

我正在尝试使用vscode中的REST Client进行POST身份验证,但是它不接受我的表单数据。这是邮递员的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"
     }
    }
   ]
  }
 }

1 个答案:

答案 0 :(得分:1)

这里的工具是一个红色的骗子,您应该检查服务器端点期望其数据使用的数据格式。通常,REST服务期望将请求作为JSON,但这并非普遍如此。

例如(包括标头和正文):

POST https://example.com/comments HTTP/1.1
content-type: application/json

{
    "UserName": "myemail@address.com",
    "Password": "My Password!",
    "RememberMe":  true
}

如果要查看服务器可能收到的内容,则可以检查诸如https://requestbin.com/之类的服务-只是不包含任何敏感数据。