我正在使用邮递员测试一些对API服务器的Curl请求。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—发布于 2016-05-06 09:32:05
一个更简单的办法是:
发布于 2017-08-12 10:31:44
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发布于 2017-06-21 11:41:10
我试过Onkaar Singh提到的方法,
但问题是,这并不适用于需要授权的Apis。
这是我的卷发要求:
curl -v -H "Accept: application/json" -H "Content-type:
application/json" -X POST -d '
{"customer_id":"812122", "event":"add_to_cart", "email": "abc@def.com", }'
-u 9f4d7f5445e7: https://api.myapp.com/api/event导入主体正确导入后,头和Url也被导入。只有api键9f4d7f5445e7,它是
-u 9f4d7f5445e7: https://api.myapp.com/api/v1/event 在curl请求中没有导入。
我解决它的方法是,-u基本上是用来授权的。因此,在Postman中使用它时,您必须使用API键(在本例中是9f4d7f5445e7 )并执行Base64编码。一旦编码,它将返回值OWY0ZDdmNTQ0NWU3。然后添加一个新的标头,键名为Authorization,键值为Basic OWY0ZDdmNTQ0NWU3。在做了改变之后,这个请求对我有效了。
有在线Base64编码器,我使用的是http://www.url-encode-decode.com/base64-encode-decode/
希望能帮上忙!
https://stackoverflow.com/questions/27957943
复制相似问题