Best answer

Looping through items in an array.

  • 27 January 2024
  • 4 replies
  • 202 views

Userlevel 1

My data comes in via a webhook and is formatted as shown below. When I attempt to loop through the line items I am only getting the first line item. What step am I missing to be able to go through these line items? Specifically I am trying to add records to a Google Sheet and Airtable base, but I can handle those action steps just fine as long as I can get the results for all line items.

 

Again, what step am I missing to be able to go through these line items?

 

 

icon

Best answer by rmwarner 30 January 2024, 19:27

View original

4 replies

Userlevel 7
Badge +14

Hi @rmwarner 

Even though the field names say “Line Items”, the data is not actually structured as Line Items.

Each field is its own variable.

 

If you have control over how the data is being sent to the webhook, then that may be the best place to fix the issue with the structure of the data to be an array.

Since it’s likely there can be N line items, you may have to get the RAW webhook data payload, then use a Code step to create arrays, to then use in the Looping app.

 

Resource to reference.

 

If you need help, consider hiring a Certified Zapier Expert.

Userlevel 1

Thanks @Troy Tessalone 

 

The good news is that I am the one who structures the payload being sent. The interesting thing is that when I look at what is actually being sent, the JSON does actually reflect that it is an array, so I’m not entirely sure where the disconnect is…


For what it’s worth, when I catch the same Webhook in Make.com, it does show up as an array, as I expect to…

Userlevel 7
Badge +14

@rmwarner

We would need to see screenshots with how the Zap webhook trigger step is configured and how the webhook is configured in the source app to have more context.

Userlevel 1

@Troy Tessalone - Figured it out! I was able to simply add a header from my source to help Zapier know how the data was formatted and we’re all good to go now. Thanks for your help.

Header

Content-Type: application/json

Reply