I have a rest request in spring integration flow. How to pick the value from the payload or header from message and set the query parameter of url
.handle(Http.outboundGateway(UriComponentsBuilder.fromHttpUrl("localhost:8080).path("search").queryParam("order", "orderId").toUriString())
.httpMethod(HttpMethod.GET)
.expectedResponseType(Order.class))
In the above code, i need to fetch the orderId from payload
If you insist to use UriComponentsBuilder
, then something like this:
.handle(Http.outboundGateway(m ->
UriComponentsBuilder.fromHttpUrl("localhost:8080")
.path("search")
.queryParam("order", m.getPayload())
.build())
.httpMethod(HttpMethod.GET)
.expectedResponseType(Order.class))
Or like this:
.handle(Http.outboundGateway(m -> servieUrl + "/search?orderId={orderId}")
.uriVariable("orderId", m -> m.getPayload())
.httpMethod(HttpMethod.GET)
.expectedResponseType(Order.class))