Forum Discussion
If the first HTTP Client always returns Array with only one element, then you can convert that Array into String and then route the record to the next HTTP Client(depending if "file" key is present or not), using Router Snap.
If first HTTP Client returns Array with multiple elements, and you need to check every element, then the best is to split that Array using JSON Splitter Snap and route the records using Router Snap, based on that presence of the "file" key field.
BR,
Spiro Taleski
- jfpelletier2 years agoContributor
Hello SpiroTaleski,
Thanks very much for your reply! It works for a simple case, however I realized that my use case might be a bit more complex. Here's with a bit more details...
In the initial JSON that I'm getting from the HTTP Client call, which is an array of JSON objects, I have to keep and use at least two elements from the initial response. The array contains JSON objects that describe a project, including values such as the project name, it's ID, and other elements that I might need at some point. It does not however contain the JSON with the potential "file" key that I also need, I have to do another call for that, using the "id" that I got from the first call.
Please have a look at the illustration below. It shows the process where I need to first get the project name and ID of each project on a server, then using the value of the ID I need to make another call to get the file name(s) and path(s) if they exist. If there is no file in the project, then no action is required.
I think that I would need to use a "join" snap to create a new JSON as new payload for the next call, with a condition (set by the router) that would consider only when the "file" element exists, correct? Or is there a better way?
Thanks a lot again!
JF