Is it possible to do a find/create step in an HTTP module?

Hello!

I have a question, I have a scenario where I create tracks via API - however, it is currently creating duplicates, which I would like to prevent.

Is there a way I can set up an HTTP module to find the track, and if it’s not found,d create the track - but if it is found, append that track ID to an array?

The reason I am not using a router is because I need both found and created track IDs in the same array to create the album at the end of the scenario and I have not found a way to merge two routes back into one - so I feel like this has to happen without a router.

Ideally I’d have find/create step but the API I am using does not have that option, so I will have to do an HTTP to find, and ideally skip the create (section 2) for those.

Any ideas on how to manage this would be greatly appreciated!

See below for an image of my scenario.

Never mind, I have found a solution!

First, iterate over the product to find all matching tracks and add those to an array of "found tracks. Also, create a comma-separated list of those tracks to be able to use as a filter.
Then iterate again over the product to create any tracks that are not on the “found tracks” array, using the comma-separated list as a filter, and create an array of “created tracks”
Then, at the end iterate over the “found tracks” array and merge it with the “created tracks” array. That final array can be used to create the album

2 Likes