Bad Request when sending message to Extension PubSub

I got this error response when trying to update the broadcaster configuration. This is a generic error, and is not only for PubSub requests.

In my case, the problem was that I had to encode non-ascii characters. I simply used the code here:

and that was it.