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

当前回答

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

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

其他回答

如上面的多个答案所述,您可以直接在POSTMAN中导入cURL。但如果URL是授权的(或由于某种原因不工作) 我建议您可以手动将所有数据点作为JSON添加到邮差体中。从cURL中获取API URL。

对于授权部分-只需添加一个授权密钥和基于64编码的字符串作为值。

例子:

curl -u rzp_test_26ccbdbfe0e84b:69b2e24411e384f91213f22a \ https://api.razorpay.com/v1/orders -X POST \——data "金额=50000" \——data "货币=INR" \——data "收据=收据#20" \——data "payment_capture=1" https://api.razorpay.com/v1/orders

{ “金额”:“5000”, “货币”:“INR”, “收据”:“收据#20”, “payment_capture”:“1” }

标题: 授权:基本cnpwX3Rlc3RfWEk5QW5TU0N3RlhjZ0Y6dURjVThLZ3JiQVVnZ3JNS * * * U056V25J 其中“cnpwX3Rlc3RfWEk5QW5TU0N3RlhjZ0Y6dURjVThLZ3JiQVVnZ3JNS***U056V25J”是“rzp_test_26ccbdbfe0e84b:69b2e24411e384f91213f22a”的编码形式

小提示:对于编码,你可以很容易地去你的chrome控制台(右键单击=> inspect)并输入: Btoa(“你想编码的字符串”)(或使用邮递员基本授权)

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

如果我们在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请求粘贴到请求页面的URL部分。 这接受CURL与小差异和CURL从chrome复制作为CRUL命令也。

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发送命令