我正在使用邮差测试一些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—
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
根据上面的答案,它工作得很好。
如果我们在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