When testing some REST API, I'm using a cURL command.
However when the request failed, it seems that cURL does not indicate that there was a non-success status code (HTTP/2 405
in my case); instead I just see the response (which is a JSON "messages" array).
As it would require "quite a lot of AI" to deduce from the contents of the message array that there was an error, I wonder how I can reliably detect the non-success status code when using cURL.
Maybe it could even be a bug in cURL (regarding use of HTTP/2).
Example session (I deliberately mad a request error to demonstrate):
> curl -u monitor 'https://redacted.server.name/api/status/get-token'
Enter host password for user 'monitor':
{
"messages": [
"The global command get-token requires to use PUT"
]
}
> echo $?
0