0

How to create the JSON in the integration flow. I want to send the JSON

{
   "username": "user",
   "password": "password1"
}

to the URL http://localhost:8051/session

My integration flow builder is:

.integrationFlowBuilder
.handle(Http.outboundGateway("http://localhost:8051/session")
            .httpMethod(HttpMethod.POST).expectedResponseType(String.class))
Mike
  • 541
  • 1
  • 4
  • 18

1 Answers1

1

I think we need more context on the matter...

From big height you can just create such a JSON string statically in the transform():

.transform(p -> "{
   \"username\": \"user\",
   \"password\": \"password1\"
}")

you have some POJO on the matter, it can be converted to JSON automatically via MappingJackson2HttpMessageConverter in the RestTemplate.

You also can use an ObjectToJsonTransformer before sending to that Http.outboundGateway().

So, please, tell us more what you have so far and what kind of information you would like to have converted to the JSON.

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118