Question

How to send an array in webhook?

  • 28 June 2022
  • 4 replies
  • 1644 views

Userlevel 1

Hello,

I’ve got a very basic question for anyone familiar with webhooks and posting data.

I have a two step Zap where I:

  1. Get a sale from a system
  2. Post the sale back to the system with one line item amended

I can “get” the data very easily and successfully.

However, when I post it back, I can’t figure out how to handle the array. The API I am using specifies that I send products back as an array of objects called “register_sale_products”, but how do I actually do this in my zap?

Do I have one field with the key named “register_sale_products” and then all my data inside it, with zapier using its line items? Or do I create each field as its own key? I’m not really sure how to get this data back into the post request correctly.

A screenshot of the two examples I’ve tried is below. What am I missing?

 


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

4 replies

Userlevel 1

I’ve started looking at this guide but have gotten stuck on the Formatter. I’m not sure if I am heading down the right path. If I am, why isn’t the formatter working?

 

Userlevel 7
Badge +14

Hi @Doc 

Good question.

Try using the Formatter > Utilities > Line Itemizer

 

Line Itemizer

If you need to create more than one set of line items, use the Line Itemizer transform:

  • In the Set up action section, click the Transform dropdown menu and select Line Itemizer (Create/Append/Prepend).
  • (Optional) In the Line-item(s) Group Name field, enter a name for your line item set.
  • In the Line-item Properties section, add your line items:
    • In the field on the left, enter a property name.
    • In the field on the right, click the field and select a trigger field with information formatted as comma-separated values.
    • Repeat this step for each set of line items.
  • Click Continue.

Line itemizer properties

Userlevel 1

Thanks @Troy Tessalone. I’ve done that and it worked to get my line items into the correct array. Great!

 

Now, how do I get that into my post request? When I got back to my webhook post request it is no longer a single output but all of the items as a separate option, much like before.

Formatter input:

 

Formatter output:

 

Webhook post request:

 

Userlevel 7
Badge +14

@Doc 

Are you trying to get this field formated in JSON?

 

Give this a try...

Formatter > Utilities > Line Items to Text (this will combine the line items)

 

EXAMPLE

 

RESULTS

 

NOTE: An advanced approach is to use 1 Code step: https://zapier.com/apps/code/help