I run several times this command

curl -X POST \
        -H "X-Primotexto-ApiKey: 784155ceed9d0a4d1ffdb67466" \
        -H "Content-Type: application/json" \
        -d "$fragment" \

Is that possible to ask curl to return the HTTP 200 (OK) ?


  • 1 Is 200 the server's response? 2 What do you mean by "return"? Print it? Print it alongside the actual answer? – PerlDuck Oct 13 '18 at 16:05
  • Sorry for the lack of precision (not an expert in curl) 1. yes 2. yes "print" alongside the actual answer – Louis Oct 15 '18 at 6:57

This command

curl --head \
     --output /dev/null \
     --write-out "%{http_code}\n" \
     --silent \
     -X POST https://api.primotexto.com/v2/notification/messages/send

will fetch the header only, redirect the output to /dev/null, silence any progress bars, and eventually print the http_code (200).

If you instead want to print the content of the website alongside the HTTP returncode, then a simple --write-out "%{http_code}\n" will do:

curl --write-out "%{http_code}\n" \
     -H "…" \
     -H "…" \
     -d "…" \
     -X POST https://api.primotexto.com/v2/notification/messages/send



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.