What is the correct way to submit the content-type header via
curl
?
Using the -H
parameter, as you specify:
-H "Content-Type: application/json"
On the other hand, you have also specified the -o
(output to file) option, without specifying a file:
If you want a progress meter for HTTP POST or PUT requests, you need to redirect the response output to a file, using shell redirect (>), -o [file] or similar.
(from man curl
)
So the command becomes:
$ curl -o output.txt -H "Content-Type: application/json" -X POST -d '{"username":"username","password":"password"}' http://localhost:8080/myproject/login
(NB I have also replaced smart quotes in the above command as they have made their way into your question)
Should submit the header and output (to output.txt
) as you specify. You could also leave off the -o output.txt
parameter if you do not require that. Although the man curl
page doesn't seem to specify it, in testing -v
cannot be mixed with -o
.