Issues with Webhook JSON Parsing & Token Handling in Marketo
Hi Marketo Community,
I’m currently working on a webhook integration in Marketo and am facing issues with passing tokens within the JSON payload, specifically due to quotation marks.
The integration requires sending the User ID as part of the JSON request to an external API. Here’s an example of the JSON payload I’m trying to use:
{
"id": {
"Userid": "{{lead.User ID:default=edit me}}"
}
}
When trying to pass the token {{lead.User ID}} in JSON, it needs to be enclosed in quotes (e.g., "Userid": "{{lead.User ID}}").
However, this causes JSON errors if the quotation marks aren’t handled properly, resulting in malformed JSON.
I have tried the following:
- Using json=escape: "Userid": "{{lead.User ID:json=escape}}"
- Concatenating with an empty string to force string output: "{{lead.User ID}}{{lead.Empty String}}"
- Adding escaped quotes "\"{{lead.User ID}}\""
- Using Velocity Script Tokens to try and build the JSON payload dynamically, but this also didn’t resolve the issue.
Despite all of this, the payload still fails due to improper token handling or JSON parsing errors.
Has anyone successfully used tokens within JSON payloads for Marketo webhooks? Are there best practices to ensure proper token handling in JSON without causing parsing issues?
Any advice or solutions would be greatly appreciated!
