Best approach to handle multiple api calls during a http in flow


Im looking for advice on best way to handle multiple api requests triggered by an incoming http post.

Sample scenario-
HTTP In node A accepts a POST with some data
Call api service B (GET) to lookup data from payload
Call api service C (POST) to lookup data from payload
Call api service B (POST) to update data combined from A, B and C
Respond to A to complete request.

msg is being used throughout so how can I call and respond to each api and close off the original call A at the end.


I assumed you have tried connecting them all in series and it fails?

If you provide self contained demo flow that I can simply import, I will show you how to do this.

You can use 3 sets of HTTP-IN → function/change → HTTP-Repsonse nodes to imitate the APIs

Unfotunately its sitting in an existing large nodered instance with dependencies so a bit complex to extract. Ive been assigned to work on it but dont have a lot of experience in this particular tool.

I managed to get the process working with a single http api call in between the http in and out by copying the req and res sections of the message and moving them back to complete the call at the end but it seems kind of clunky.

I guess the more abstract view is how do i make other http api calls in a flow that starts with a public endpoint hitting a http request and ending in the http response with corrupting the various msgs in between. Probably a lack of understanding on my part of msg interactions.

That is the easiest way to do it. I presume that you saved them in an unused message property. You should be able to add the other two requests in the same way, all in series.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.