作者:mobiledu2502930043 | 来源:互联网 | 2023-05-26 17:36
我使用Postman来测试一些针对API服务器的Curl请求.API开发人员给了我们curl命令,但是我不能用Postman发送它.如何提出这样的要求?
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
—0xKhTmLbOuNdArY—
Onkaar Singh..
297
一种更简单的方法是:
打开POSTMAN
单击左上角的"导入"选项卡.
选择"原始文本"选项并粘贴cURL命令.
点击导入,您将在Postman构建器中获得命令!
希望这可以帮助!
1> Onkaar Singh..:
一种更简单的方法是:
打开POSTMAN
单击左上角的"导入"选项卡.
选择"原始文本"选项并粘贴cURL命令.
点击导入,您将在Postman构建器中获得命令!
希望这可以帮助!
我尝试了它,它部分工作.这是我的curl请求:`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`导入正确导入的正文后,标题和网址也得到了进口.只有卷曲请求中的"-u 9f4d7f5445e7:https:// api.myapp.com/api/v1/event"的api密钥9f4d7f5445e7没有导入或者可能是Postman跳过它.知道怎么解决吗?
在看到这篇文章之前,我不知道您能做到这一点。谢谢!
2> electricalba..:
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
3> Rito..:
我尝试了Onkaar Singh提到的方法,
打开邮递员
单击左上角的“导入”选项卡。
选择“原始文本”选项,然后粘贴您的cURL命令。
点击import,您将在Postman构建器中获得命令!
但是问题是,这对于需要授权的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/
希望能帮助到你!!!