Create POST Request with Postman

1.3k views Asked by At

This curl is working fine and returns the token as expected:

curl -X POST -H "X-Requested-With: XMLHttpRequest" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{ "username": "[email protected]","password": "password" }' "http://75.90.255.68:1133/canPeris/auth"

But when I do the same call using Postman app I get a 401 Unauthorized as a return value

enter image description here

2

There are 2 answers

0
Ori Marko On BEST ANSWER

You should add the missing JSON inside the Body . click Raw combo box and add

{ "username": "[email protected]","password": "password" }
0
René On

You can use the function in Postman to generate curl: https://www.getpostman.com/docs/v6/postman/sending_api_requests/generate_code_snippets

On the right side under "Send" and "Save" just hit the Code Button/Link. Then select in the next window in the drop down cURL. So you see what cURL would be generated and compare it with the command line.

The -d option is described here: https://curl.haxx.se/docs/manpage.html#-d