How do I build up a payload in Mule?

247 views Asked by At

I want to make 3 calls to different systems and want to add the information from each query result to the payload object.

My experience up to now is that the query result from call 2 would overwrite call 1 so what is the best way to add the values to the payload without overwriting it as I need call 1-3 to populate a main JSON object?

I'm currently trying to figure out the best design for this so no example XML at the moment.

Thanks

1

There are 1 answers

0
Anirban Sen Chowdhary On

What you can do is you can use Mule message enricher and inside it, you can call other query and store the result in a variable. Using a message enricher will not overwrite the existing payload and let you to store all the query result in a variable.
You can find message enricher reference here :- https://docs.mulesoft.com/mule-user-guide/v/3.8/message-enricher

Now, once you stored all the results of the calls in variables using enricher, if you need to combine the main payload with those, you can use either a Dataweave component or an expression transformer to populate and modify existing JSONpayload