RabbitMQ REST HTTP JSON payload
Working example. We need simple to escape doublequotes. It is important that the colon is outside of the quotes, as this causes inexplicable errors.
{
"properties": {},
"routing_key": "q_testing",
"payload": "{
\"message\": \"message from terminal\"
}",
"payload_encoding": "string"
}
Try with
{
"properties": {
"content-type": "application/json"
},
"routing_key": "testKey",
"payload": "1234",
"payload_encoding": "string"
}
I managed to send content-type using underscore "_" instead of dash.
See here for list of valid properties. See RabbitMQ Management HTTP API for some examples.
To publish a json message using curl to rabbit exchange:
curl -i -u guest:guest -XPOST --data '{"properties":\
{"content_type":"application/json"}, \
"routing_key":"", \
"payload":"{\"foo\":\"bar\"}",\
"payload_encoding":"string"}' \
"http://localhost:15672/api/exchanges/%2f/exchange_name/publish"
content_type is written using underscore, routing_key is empty to send a message to exchange, not to particular queue.