我正在使用邮差测试一些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—

当前回答

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

如果我们在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

其他回答

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

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

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

我完全转向失眠应用程序解决了这个问题。

打开失眠应用程序,并将CURL请求粘贴到请求页面的URL部分。 这接受CURL与小差异和CURL从chrome复制作为CRUL命令也。

1)在url输入框中输入https://api-server.com/API/index.php/member/signin,在下拉框中选择POST

2)在Headers页签中输入:

内容类型:图像/ jpeg

Content-Transfer-Encoding:二进制

3)在Body选项卡中,选择raw单选按钮并写入:

{“描述”:“”,“电话”:“”,“姓”:“”,“app_version”:“2.6.2”、“firstname”:“”,“密码”:“my_pass”、“城市”:“”,“apikey”:“213”,“朗”:“fr”、“平台”:“1”,“电子邮件”:“email@example.com”、“伪”:“例子”}

选择form-data单选按钮并写入:

key = name Value = userfile选择文本 选择文件并上传你的profile .jpg

这里有一个直观的答案

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

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