robotframework-requests icon indicating copy to clipboard operation
robotframework-requests copied to clipboard

Better error message when expecting JSON but get 204 (No content) response

Open Eli-Black-Work opened this issue 2 years ago • 1 comments

If we do a GET request that expects a JSON response, like so:

${response}=  RequestsLibrary.GET  ${url}

then if the server returns 204 (no content) instead of returning JSON, we get this error:

Replacing variables from keyword return value failed: Resolving variable '${response.json()}' failed: JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I think it'd be nice to have a friendly error message for this. Perhaps something like Expected the response to contain JSON, but the response was 204 (No Content) 🙂

Eli-Black-Work avatar Dec 21 '22 04:12 Eli-Black-Work

Would be nice having a flask test endpoint to show this issue, but ok I think I understood the point, needs investigation.

lucagiove avatar Oct 26 '24 12:10 lucagiove