Solved

Invalid JSON for Webhook

  • 8 March 2023
  • 2 replies
  • 148 views

Badge +1

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. 

 

icon

Best answer by stem 8 March 2023, 19:57

View original

2 replies

Userlevel 2
Badge +5

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":}

 

Badge +1

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. 

Reply