Mulesoft Anypoint Studio - pass the id from my variable into flow-reference

117 Views Asked by At

Could you please help? I am new to Mulesoft Anypoint studio and can't seem to find the right way to do this - been stuck with this for a rediculously long time: I have many endpoints defined within a single Mulesoft project. One of the endpoints is like this: persons/(id) where id is a URI parameter, and providing the id will give back json file about the person with that id. This endpoint has a Listener.

I am now doing another flow within the same project POST "/createGroup" where i take in a list of personsIds and create a group for them. I want to pre-validate each of the ids that are inputted as list into my query Parameter "persons". I go through the list of the ids,and at this point individual inputted id is stored in my variable PersonId. I want to call persons/(id) via Flow-reference but am struggling to pass vars.PersonId into the id. How do i do this correctly? thanks so much in advance!

1

There are 1 best solutions below

2
aled On

You are mistaken. The name of a flow is a literal string and doesn't depend on variables.

Flow reference will work. Having said that, the name looks like one of the auto generated flow by APIKit scaffolding at design time. If an APIKit router is normally calling that flow a manual flow ref may be missing some metadata that APIKit adds for it to work. That's is something you should see when you test it.

If your flow is called "get:\persons(id):myproject-config" then that´s exactly what your flow ref should use. (id) is not a variable or a parameter. What flow-ref does is to trigger a flow in the application. You need to send the same payload that the flow expects, in this case what the APIKit router sends when it triggers the flow.

You could instead send an HTTP request to the listener request, it just consumes much more resources than a flow ref and is not as performant.