我正在尝试通过 Postman 发送一个普通的 POST 请求。我通过 Curl 做了同样的事情,我的服务器认为它很好。这是 Body 的设置:
这是控制台中的请求:
我的快递服务器没有看到正文变量。像这样卷曲它:
curl -X POST https://xxx.appspot.com -d "volume=123&content=foobar"
我需要更改什么才能使其正常工作?
答案 0 :(得分:1)
这两个示例并不等效,因为使用 Postman 时,您设置了 Content-Type: text/plain
标头,但通过 curl -d
选项发送数据,设置了 Content-Type: application/x-www-form-urlencoded
。来自 curl
手册页:
-d, --data <data>
(HTTP MQTT) Sends the specified data in a POST request to the
HTTP server, in the same way that a browser does when a user has
filled in an HTML form and presses the submit button. This will
cause curl to pass the data to the server using the content-type
application/x-www-form-urlencoded.
我对 Postman 没有任何经验,但我猜您需要选择 x-www-form-urlencoded
按钮而不是当前的 raw
按钮。