I am using Postman to test some Curl requests to an API server. The API developers gave us the curl command, but I can\'t send it from the Postman. How to make such a reques
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
A simpler approach would be:
Hope this helps!
As per the above answers, it works well.
If we paste curl requests with Authorization data in import, Postman will set all headers automatically. We only just pass row JSON data in the request body if needed or Upload images through form-data in the body.
This is just an example. Your API should be a different one (if your API allows)
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
1) Put https://api-server.com/API/index.php/member/signin
in the url input box and choose POST
from the dropdown
2) In Headers tab, enter:
Content-Type: image/jpeg
Content-Transfer-Encoding: binary
3) In Body tab, select the raw
radio button and write:
{"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"}
select form-data
radio button and write:
key = name Value = userfile Select Text
key = filename Select File
and upload your profil.jpg
As mentioned in multiple answers above you can import the cURL in POSTMAN directly. But if URL is authorized (or is not working for some reason) ill suggest you can manually add all the data points as JSON in your postman body. take the API URL from the cURL.
for the Authorization part- just add an Authorization key and base 64 encoded string as value.
example:
curl -u rzp_test_26ccbdbfe0e84b:69b2e24411e384f91213f22a \ https://api.razorpay.com/v1/orders -X POST \ --data "amount=50000" \ --data "currency=INR" \ --data "receipt=Receipt #20" \ --data "payment_capture=1" https://api.razorpay.com/v1/orders
{
"amount": "5000",
"currency": "INR",
"receipt": "Receipt #20",
"payment_capture": "1"
}
Headers:
Authorization:Basic cnpwX3Rlc3RfWEk5QW5TU0N3RlhjZ0Y6dURjVThLZ3JiQVVnZ3JNS***U056V25J
where "cnpwX3Rlc3RfWEk5QW5TU0N3RlhjZ0Y6dURjVThLZ3JiQVVnZ3JNS***U056V25J" is the encoded form of "rzp_test_26ccbdbfe0e84b:69b2e24411e384f91213f22a"`
small tip: for encoding, you can easily go to your chrome console (right-click => inspect) and type :
btoa("string you want to encode")
( or use postman basic authorization)
sometimes whenever you copy cURL, it contains --compressed. Remove it while import->Paste Raw Text-->click on import. It will also solve the problem if you are getting the syntax error in postman while importing any cURL.
Generally, when people copy cURL from any proxy tools like Charles, it happens.