[rabbitmq-discuss] Posting a json body as payload using the http api

dilipl dilip.ladhani at gmail.com
Tue Jul 24 23:59:45 BST 2012


Hey guys,

I can post a json message using the java client. I use the spring amqp
plugin and able to post a json using the amqpTemplate.convertAndSend call.

I know the http management api is not for heavy loads, but for a small piece
of our app, we use the http call to Rabbit. Now this worked fine, when my
payload was a simple String. It *does not work*, when I use json as the
body. I am thinking the json needs to be escaped somehow? I am actually able
to post the msg, but can't retrieve it using the rabbit console or a java
listener.

*This sample does not work*
http://localhost:55672/api/exchanges/%2F/my.exchange/publish
{
    "properties": {
        "content-type": "application/json"
    },
    "routing_key": "myKey",
    "payload": {
        "abc": "1.0",
        "deg": "XY",
        "dhi": "AB",
        "jkl": "654654",
        "mno": "CREATED",
        "pqr": "SYSTEM",
        "rst": "1.0",
        "uvw": "LOG",
        "timestamp": "07/24/2012 9:31:12"
    },
    "payload_encoding": "string"
}

*This does work*
http://localhost:55672/api/exchanges/%2F/my.exchange/publish
{
    "properties": {
        "content-type": "application/json"
    },
    "routing_key": "myKey",
    "payload": "1234",
    "payload_encoding": "string"
}



--
View this message in context: http://rabbitmq.1065348.n5.nabble.com/Posting-a-json-body-as-payload-using-the-http-api-tp21034.html
Sent from the RabbitMQ mailing list archive at Nabble.com.


More information about the rabbitmq-discuss mailing list