1
votes

I need to pass a post request parameters to an int-http:outbound-gateway and can't find any simple way to do this. What I have to do is issue a http request to a couch db fetching multiple documents with a single request as described in the couch db documentation:

curl -d '{"keys":["bar","baz"]}' -X POST http://127.0.0.1:5984/foo/_all_docs?include_docs=true

So how do I pass the param with the name 'keys' to the int-http:outbound-gateway? (I have all the data I need in the payload of the message)

<int-http:outbound-gateway request-channel="requestChannel" 
                     url="http://127.0.0.1:5984/foo/_all_docs?include_docs=true" 
                     http-method="POST"
                     expected-response-type="java.lang.String"/>
1

1 Answers

1
votes

The payload of the inbound message becomes the body of the POST; selected headers are mapped and you can control that with a number of header mapping options; see the documentation.

If you need to transform some java object to the JSON above, you can add a transformer upstream of the gateway, or configure a custom MessageConverter into the gateway itself.

Your curl command is sending the JSON as the body of the POST; the gateway will do the same thing.