Skip to main content
Contributor I
March 8, 2023
Solved

Invalid JSON for Webhook

  • March 8, 2023
  • 2 replies
  • 329 views

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. 

 

    This topic has been closed for replies.
    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
    stemAnswer
    Problem Solver III
    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":}

     

    S Klotz (they/them) - novica.com
    edIconAuthor
    Contributor I
    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.