I a using Postman to test some Curl requests to an API server. The API developer gave us the curl command, but I can't send it with Postman. How to make such a request?
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—
A simpler approach would be:
Hope this helps!
I tried the approach mentioned by Onkaar Singh,
But the problem is it didn't work for the Apis which requires authorisation.
This was my curl request:
After importing the body got imported correctly, the headers and the Url also got imported. Only the api key 9f4d7f5445e7 which is
in the curl request did not import.
The way I solved it is, -u is basically used for Authorization. So while using it in Postman, you have to take the API key (which is
9f4d7f5445e7
in this case) and do Base64 Encode. Once encoded it will return the valueOWY0ZDdmNTQ0NWU3
. Then add a new header, the key name would beAuthorization
and key value would beBasic OWY0ZDdmNTQ0NWU3
. After making that changes, the request worked for me.There are online Base64 Encoders available, the one I used is http://www.url-encode-decode.com/base64-encode-decode/
Hope it helps!!!
1) Put
https://api-server.com/API/index.php/member/signin
in the url input box and choosePOST
from the dropdown2) 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 SelectFile
and upload your profil.jpg