如何将以下 cURL 命令转换为 Postman rest 调用?
curl -X POST abc.com/input.import
-H 'content-type: application/x-www-form-urlencoded'
--data-urlencode "apiKey=123-456"
--data-urlencode "secret=12/her"
--data-urlencode "userKey=ApUR"
--data-urlencode "email=fakeImportedAccount@example.com"
--data-urlencode "profile={'firstName':'John','lastName':'Kira'}"
我尝试了以下方法:网址:(POST)abc.com/input.import
标题:内容类型:应用程序/json
body :
{
"apiKey":"123-456",
"userKey":"ApUR",
"secret":"12/her",
"email":"fakeImportedAccount@example.com",
"profile": {
"firstName":"John",
"lastName":"Kira"
}
}
编辑:需要 Postman 中的原始正文格式。导入以 "x-www-form-urlencoded"
形式创建请求
最佳答案
内容类型不是 application/json
,它是 application/x-www-form-urlencoded
.您需要做的是在正文选项卡中,选择 application/x-www-form-urlencoded
.内容类型标题将自动为您设置。刚刚开始添加键/值对(--data-urlencoded 参数)
更新
不相关,但对于那些正在寻找发布 JSON 的方式(这很常见)的人,您可以使用“原始”单选按钮,然后您将手动将 JSON 输入到他们提供的窗口中。你也可以设置 Content-Type
标题到 application/json
.
关于rest - 将 cURL 转换为 Postman REST 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52593017/