What is the correct way to submit the content-type header via
curl?
Usando o parâmetro -H , conforme você especifica:
-H "Content-Type: application/json"
Por outro lado, você também especificou a opção -o (saída para arquivo), sem especificar um arquivo:
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.
(de man curl )
Então o comando se torna:
$ curl -o output.txt -H "Content-Type: application/json" -X POST -d '{"username":"username","password":"password"}' http://localhost:8080/myproject/login
(NB eu também substituí as citações inteligentes no comando acima como eles fizeram o seu caminho em sua pergunta)
Deve enviar o cabeçalho e a saída (para output.txt ) conforme você especificar. Você também pode deixar o parâmetro -o output.txt se não exigir isso. Embora a página man curl não pareça especificá-la, no teste -v não pode ser misturada com -o .