I just wanted to know what is the way to get the return code from the curl command. Likewise, if trigger the same curl from postman client we are able to get all error messages.
Currently, I am just able to get the return code as "0" in case of success but I wanted "200" and other return code with respect to the command.
curl -X POST http://localhost:4449/api/messages -H 'accept: application/json' -H 'authorization: Basic cmVsYXktnruDFjEyMw==' -H 'content-type: application/json' -d "{\"cloudDelivery\":\"$cloudDelivery\"}"
Use the -I option to get the status code on the first line of the response:
$ curl -I www.google.com
HTTP/1.1 200 OK
Date: Wed, 06 Feb 2019 12:58:31 GMT
...
There is a whole exchange about this question here.
They propose a simple way to get only the code with the next command:
curl -s -o /dev/null -I -w "%{http_code}" http://www.example.org/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With