rest - 将 cURL 转换为 Postman REST 调用

标签 rest curl postman

如何将以下 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 参数)
enter image description here
更新
不相关,但对于那些正在寻找发布 JSON 的方式(这很常见)的人,您可以使用“原始”单选按钮,然后您将手动将 JSON 输入到他们提供的窗口中。你也可以设置 Content-Type标题到 application/json .

关于rest - 将 cURL 转换为 Postman REST 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52593017/

相关文章:

android - 如何在不使用 pushover 的情况下使用 http POST 向我的 Android 手机发送通知?

postman - 在Postman中使用不同的数据多次运行请求仅运行一次

java - Rest Web 服务不返回 JSON 数组

java - 如何在REST函数的ResponseBuilder中调用Javascript函数?

curl - cURL 请求中 -vvv 选项的含义是什么

php - 将文件上传到 PHP 的 Curl PUT 请求

c# - 无法在 C# 中反序列化 JSON 结果。输入字符串格式不正确错误

ios - 如何使用 Swift 2.0 在 Parse.com (REST API) 中上传图像并将其与用户关联

javascript - 用于日期分配的 Postman 先决条件函数

azure - 为什么 jwt.io 无法解码 google JWT token