curl write http code to stderr or to file
I found a way around this issue by using -o
to redirect just the content to a temporary file, leaving just the status code in the curl's output.
I can then read the contents of the temporary file from python -m json.tool
and pretty print them.
For example,
content=$(mktemp)
curl \
...
-w \
'HTTP_STATUS_CODE: %{http_code}\n' \
...
-o \
"$content" \
-- \
'https://somecompany.com/some_api_endpoint'
<"$content" python -m json.tool