我正在尝试将下面的curl请求转换为postman工具的HTTP请求 . 在这个问题中,邮递员工具可能并不重要 . 请告诉我如何将curl转换为http .
curl -X POST -i 'https://a-webservice.com' -H X-apiKey:jamesBond007 -d MESSAGE-TYPE="pub.controller.user.created" -d PAYLOAD='a json object goes here!'
What I tried/learned: - 设置 Headers 内容类型:json / application,X-apiKey
- 来自curl docs,-d选项意味着我们需要设置内容类型application / x-www-form-urlencoded
Postman让我使用4个选项中的1个 - 表格数据,x-www-form-urlencoded,raw,binary来设置请求正文 . 你能说明我如何将两个卷曲选项转换成这些选项吗?
我很困惑如何把它们放在一起 .
谢谢!
3 回答
我没有't know much about Postman. But I captured what'被发送到一个名为
/tmp/ncout
的文件中 . 基于此,我们看到正在发送的Content-Type是application/x-www-form-urlencoded
,正如您所确定的那样,并且发送的有效负载是MESSAGE-TYPE=pub.controller.user.created&PAYLOAD=a json object goes here!
.这有帮助吗?
这是一个如何使用python执行此urlencode的示例:
application/x-www-form-urlencoded
数据的格式与查询字符串相同,因此:要确认这一点,您可以使用the --trace-ascii option转储
curl
本身的请求数据:--trace-ascii
采用文件名作为参数但是如果你给它-
它会转储到stdout
.上面调用的输出将包括以下内容:
所以与使用
nc
的Convert curl request into http request?的答案中确认的相同,但使用--trace-ascii
选项确认只使用curl
本身 .