Question

Webhook Catch is not parsing JSON

  • 7 October 2020
  • 2 replies
  • 838 views

Userlevel 4
Badge +5

I am using a POST request to a Zapier Webhook Catch Hook.  When I receive the JSON, it is not being parsed into each unique field.  Any Ideas?   Here is the JSON:

{
"Invoices": [
{
"Customer": "ZenWTR",
"Email": "jq@zenwtr.com",
"Terms": "Due Upon Receipt",
"InvoiceDate": "10/5/2020",
"DueDate": "10/5/2020",
"InvoiceNbr": "2020-211",
"RecessPO": "2020-211",
"Items": [
{
"ProductService": "Event Sponsorship Fee",
"Description": "2020-10-06 - Product Sampling - El Toro Flicks - Coachella Valley Drive-In Theater",
"Qty": 1808,
"Rate": 0.5,
"Amount": 540,
"Class": "ZenWTR"
},
{
"ProductService": "Event Sponsorship Fee",
"Description": "2020-10-13 - Product Sampling - El Toro Flicks - Coachella Valley Drive-In Theater",
"Qty": 1808,
"Rate": 0.5,
"Amount": 540,
"Class": "ZenWTR"
}
]
},
{
"Customer": "Stratus Group Duo llc.",
"Email": "brooke@stratusgp.com",
"Terms": "Due Upon Receipt",
"InvoiceDate": "09/22/2020",
"DueDate": "09/22/2020",
"InvoiceNbr": "2020-190",
"RecessPO": "2020-190",
"Items": [
{
"ProductService": "Event Sponsorship Fee",
"Description": "2020-10-10 - Product Sampling@BIG Kahuna 6-Man Beachfest",
"Qty": 200,
"Rate": 0.5,
"Amount": 100,
"Class": "Stratus Group Duo llc."
},
{
"ProductService": "Event Sponsorship Fee",
"Description": "2020-09-26 - Product Sampling - Silverlake Flea Market",
"Qty": 500,
"Rate": 0.5,
"Amount": 250,
"Class": "Stratus Group Duo llc."
}
]
}
]
}

 

Here is the result of the Catch Hook:

 


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 +11

Hi @Mercology!

For nested array fields, Zapier flattens the contents of the field into a single string. If you wish to access each individually, you need to do a couple of things:

  1. Change your webhook trigger type to "Catch Raw Hook"
  2. Setup a code action step to parse the JSON payload from the trigger and extract the fields you need programatically

Code steps have a built-in library function called JSON.parse that might be able to extract the fields that you need to use in later steps. Here's an example of what I mean:

I must point out here that Code steps are an advanced feature so our support for them is limited. 

Userlevel 4
Badge +5

@nicksimard Thanks for the feedback.  I am trying to leverage all the Zapier trigger capabilities (create a separate execution perform for each item in the array received) and line item support (mapping the array of items).  This is for a custom app which sends the invoice JSON to Zapier.  Zapier processes each node in the array against Create New Quickbooks Invoice with Line Item Support.

The new JSON looks like the following.  The only issue is the Items array is not coming accross with individual array of fields.

[
{
"Customer": "ZenWTR",
"Email": "jq@zenwtr.com",
"Terms": "Due Upon Receipt",
"InvoiceDate": "10/5/2020",
"DueDate": "10/5/2020",
"InvoiceNbr": "2020-211",
"RecessPO": "2020-211",
"Items": [
{
"ProductService": "Event Sponsorship Fee",
"Description": "2020-10-06 - Product Sampling - El Toro Flicks - Coachella Valley Drive-In Theater",
"Qty": 1808,
"Rate": 0.5,
"Amount": 540,
"Class": "ZenWTR"
},
{
"ProductService": "Event Sponsorship Fee",
"Description": "2020-10-13 - Product Sampling - El Toro Flicks - Coachella Valley Drive-In Theater",
"Qty": 1808,
"Rate": 0.5,
"Amount": 540,
"Class": "ZenWTR"
}
]
},
{
"Customer": "Stratus Group Duo llc.",
"Email": "brooke@stratusgp.com",
"Terms": "Due Upon Receipt",
"InvoiceDate": "09/22/2020",
"DueDate": "09/22/2020",
"InvoiceNbr": "2020-190",
"RecessPO": "2020-190",
"Items": [
{
"ProductService": "Event Sponsorship Fee",
"Description": "2020-10-10 - Product Sampling@BIG Kahuna 6-Man Beachfest",
"Qty": 200,
"Rate": 0.5,
"Amount": 100,
"Class": "Stratus Group Duo llc."
},
{
"ProductService": "Event Sponsorship Fee",
"Description": "2020-09-26 - Product Sampling - Silverlake Flea Market",
"Qty": 500,
"Rate": 0.5,
"Amount": 250,
"Class": "Stratus Group Duo llc."
}
]
}
]

Here is the current view: