What I’m trying to do:
I’m trying to return a json object in a HttpResponse body that contains a boolean value. When executing the request from Postman I’m getting the following error:
Cannot send a Boolean object over HTTP as response[“bool_test”]. You must return either Media, a string, or a JSON-compatible object (lists/dicts/strings/numbers/None).
I would expect booleans to work or am I missing something?
You’ve encountered a self-inconsistent error message.
Yet if we look at the JSON standard, booleans are definitely JSON-compatible.
So, the error message is self-contradictory. What should we expect in that case? Nothing. Mathematically, it is not possible to draw valid conclusions from a contradictory statement.
We have to rely on observed behavior, instead, and if that’s not working, try encoding the value in some other way. Preferably, in a way that the receiving end will decode (correctly) and understand.