我正在使用邮差测试一些Curl请求到API服务器。API开发人员给了我们curl命令,但我不能从邮递员发送它。如何向邮差提出这样的要求?

curl -X POST "https://api-server.com/API/index.php/member/signin" -d "{"description":"","phone":"","lastname":"","app_version":"2.6.2","firstname":"","password":"my_pass","city":"","apikey":"213","lang":"fr","platform":"1","email":"email@example.com","pseudo":"example"}"

--0xKhTmLbOuNdArY
Content-Disposition: form-data; name="userfile"; filename="profil.jpg"
Content-Type: image/jpeg
Content-Transfer-Encoding: binary

<ffd8ffe0 00104a46 49460001 01010048 ... a00fffd9>

—0xKhTmLbOuNdArY—

当前回答

In addition to the answer
1. Open POSTMAN
2. Click on "import" tab on the upper left side.
3. Select the Raw Text option and paste your cURL command.
4. Hit import and you will have the command in your Postman builder!
5. If -u admin:admin are not imported, just go to the Authorization 
   tab, select Basic Auth -> enter the user name eg admin and password eg admin.
This will automatically generate Authorization header based on Base64 encoder

其他回答

In addition to the answer
1. Open POSTMAN
2. Click on "import" tab on the upper left side.
3. Select the Raw Text option and paste your cURL command.
4. Hit import and you will have the command in your Postman builder!
5. If -u admin:admin are not imported, just go to the Authorization 
   tab, select Basic Auth -> enter the user name eg admin and password eg admin.
This will automatically generate Authorization header based on Base64 encoder

一个更简单的方法是:

开放的邮递员 点击左上角的“导入”标签。 选择Raw Text选项并粘贴cURL命令。 点击导入,您将在您的邮差构建器中拥有命令! 单击Send发送命令

有时当你复制cURL时,它包含——压缩。 删除它,同时导入->粘贴原始文本->点击导入。 它还可以解决在导入任何cURL时在postman中出现语法错误的问题。

通常,当人们从任何代理工具(如Charles)复制cURL时,就会发生这种情况。

根据上面的答案,它工作得很好。

如果我们在import中粘贴带有授权数据的curl请求,Postman将自动设置所有头信息。如果需要,我们只在请求体中传递行JSON数据,或者在请求体中通过form-data上传图像。

这只是一个例子。你的API应该是一个不同的(如果你的API允许的话)

curl -X POST 'https://verifyUser.abc.com/api/v1/verification' \
    -H 'secret: secret' \
    -H 'email: user@gmail.com' \
    -H 'accept: application/json, text/plain, */*' \
    -H 'authorizationtoken: bearer' \
    -F 'referenceFilePath= Add file path' \
    --compressed

这里有一个直观的答案

想要一个1分钟的快速教程,请查看这个视频在邮递员中运行curl =======================================================================

在右上角找到Import按钮 选择Raw并粘贴您的curl命令,单击Continue -> Import 您可以确认请求URL、参数和头是否正确导入。