MarketSquare / robotframework-requests

Robot Framework keyword library wrapper for requests
http://marketsquare.github.io/robotframework-requests/
MIT License
488 stars 280 forks source link

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

Open Eli-Black-Work opened 1 year ago

Eli-Black-Work commented 1 year ago

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) 🙂

lucagiove commented 1 week ago

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