Bad Request 400 when trying to send pubsub message from EBS - Node.js

On my side I make sure that the message parameter is always a string.
In the documentation you can see that the message content has been encoded as a string itself.

So in your case you should change the value of message to

message: JSON.stringify({ foo: ‘bar’ })