Skip to main content
Solved

Invalid JSON for Webhook when retrieving event.extra.line_items


Forum|alt.badge.img+2

I am using the Klaviyo Flow to trigger a webhook when order is fulfilled.

I am trying to access the data contained in event.extra.line_items
 

{
    "email": "{{ person.email }}",
    "event": "{{ event.extra.line_items }}"
}

I am unable to set this as the webhook field as I am getting an invalid JSON error.

I hope this is not a bug, but my syntax should be straightforward. Appreciate if someone can point me in the right direction as to why the above returns invalid JSON error.

Best answer by David To

Hello @douglaslo,

Welcome to the Klaviyo Community!

From my perspective it looks to be formatted correctly. Did you happen to copy and paste any of these elements from another source? Oftentimes when I come across behaviors like this its usually caused by some latent formatting that gets brought over. For this reason, we always suggest pasting as plain text/pasting without formatting. 

I would also suggest double checking that the {{ event.extra.line_items }} variable you’re referencing aligns with the metric that triggers your flow. If I’m not mistaken, the {{ event.extra.line_items }} variable is usually found as part of the Fulfilled Order event so this means you’ll want to ensure that’s the metric used to trigger your flow. Along the same lines, you’ll want to make sure the pathing for this variable is correctly referencing your items as well.

I hope this helps!

David

View original
Did this topic or the replies in the thread help you find an answer to your question?

2 replies

David To
Klaviyo Employee
Forum|alt.badge.img+60
  • Klaviyo Employee
  • 2456 replies
  • Answer
  • August 25, 2022

Hello @douglaslo,

Welcome to the Klaviyo Community!

From my perspective it looks to be formatted correctly. Did you happen to copy and paste any of these elements from another source? Oftentimes when I come across behaviors like this its usually caused by some latent formatting that gets brought over. For this reason, we always suggest pasting as plain text/pasting without formatting. 

I would also suggest double checking that the {{ event.extra.line_items }} variable you’re referencing aligns with the metric that triggers your flow. If I’m not mistaken, the {{ event.extra.line_items }} variable is usually found as part of the Fulfilled Order event so this means you’ll want to ensure that’s the metric used to trigger your flow. Along the same lines, you’ll want to make sure the pathing for this variable is correctly referencing your items as well.

I hope this helps!

David


Forum|alt.badge.img+2
  • Author
  • Contributor I
  • 2 replies
  • August 29, 2022
David To wrote:

Hello @douglaslo,

Welcome to the Klaviyo Community!

From my perspective it looks to be formatted correctly. Did you happen to copy and paste any of these elements from another source? Oftentimes when I come across behaviors like this its usually caused by some latent formatting that gets brought over. For this reason, we always suggest pasting as plain text/pasting without formatting. 

I would also suggest double checking that the {{ event.extra.line_items }} variable you’re referencing aligns with the metric that triggers your flow. If I’m not mistaken, the {{ event.extra.line_items }} variable is usually found as part of the Fulfilled Order event so this means you’ll want to ensure that’s the metric used to trigger your flow. Along the same lines, you’ll want to make sure the pathing for this variable is correctly referencing your items as well.

I hope this helps!

David

Thank you for the suggestion, I copy and pasted the elements by clicking on the extra.line_items property from the event preview. I have tried pasting it as plain text with no luck. I am not sure if special Chinese characters within the JSON is causing the problem.

 

The webhook trigger is “When someone Fufilled Order”.

 

My current workaround is to only get the order number “event.extra.name” and to call Shopify’s API and retrieve the details I need via Shopify’s API. Although long winded and indrect, it ought to work.

 

Do share if you have any other suggestions.


Reply