Question

Zapier only outputs first json object, having troube useing looping


I have been given the assignment to connect our company's API to Zapier with custom connectors. This appears to be working although it only returns the first item of the JSON object (fig 1) which seems to be the norm for zapier. I added the option (fig 2) to output all data with 0.Name 0.Sequence 1.Name 1.Sequence. etc. form (fig 3), however neiither yield what we want. We have a use case that loops over all applications in our software and performs some actions with each application but zapier only does all the steps with the first one I tried to add looping and formatting but I'm just a bit to novel to really be able to apply it to our own API.

Does anyone know how I would be able to accomplish our goal of having one run loop over each application available?

 


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Userlevel 7
Badge +14

Hi @DNAmon 

You may need to try using the Code step to make the API request so it returns all the results.

Or you can try using the Webhook app to make an API request.

 

First, set up your trigger and initial API call. Begin by setting up the initial trigger for your Zap, which could be a schedule, a webhook, or another app's event. Then, use a "Webhook" action to perform a GET request to your API to fetch the list of applications. Ensure this step successfully retrieves the full JSON array of applications.

Next, use "Looping by Zapier" to iterate over applications. Add a new action after your API call, select "Looping by Zapier" as the app, and choose the "Create Loop from Line Items" event. In the "Values to Loop" field, map the array of applications from your previous step. This might look something like {{Webhooks.response_body}} where response_body is the key containing your array of applications.

Then, perform actions for each application inside the loop. Add the actions you want to perform for each application within the loop. These actions will be repeated for each item in the array. Use the data from the looping step to map individual application fields, referencing them appropriately, such as {{Looping.Name}} and {{Looping.Sequence}}.