Skip to main content
Solved

Invalid JSON for Webhook

  • March 8, 2023
  • 2 replies
  • 257 views

Forum|alt.badge.img+2

Hello,

I’m making a webhook to update a customer’s group on my website. 

The format accepted by my server is as follows:

[

    {

        "customer_id": {{ event.extra.id|default:'' }}

    }

]

When previewing the webhook, I was able to send a test request which successfully updated the value on my end.

Correct JSON format. Not validated to save, however the webhook was successfully sent.

 

In order to save my webhook, Klaviyo insists that I wrap the {{ event.extra.id|default:'' }} in quotes as shown below. This format with quotes is not accepted by my server API. 

[
    {
        "customer_id": {{ event.extra.id|default:'' }}
    }
]

Invalid JSON format. 

 

Best answer by stem

Can you set the default to -1 or 0 so that it’s also a number? The default:’’ option is probably what’s not letting you treat the value as a number.

{"customer_id":}

 

2 replies

stem
Problem Solver III
Forum|alt.badge.img+6
  • Problem Solver III
  • 20 replies
  • Answer
  • March 8, 2023

Can you set the default to -1 or 0 so that it’s also a number? The default:’’ option is probably what’s not letting you treat the value as a number.

{"customer_id":}

 


Forum|alt.badge.img+2
  • Author
  • Contributor I
  • 1 reply
  • March 8, 2023

Can you set the default to -1 or 0 so that it’s also a number? The default:’’ option is probably what’s not letting you treat the value as a number.

{"customer_id":}

 

You solution works. I’m able to save the webhook now.

It should be noted that simply removing the “default” option does not work. I now understand that setting default to -1 tells Klaviyo to treat the data as a number rather than a string.

Thank you for your help.