SOLVED

Issues with Webhook JSON Parsing & Token Handling in Marketo

Go to solution
dtavangar
Level 2

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!

2 ACCEPTED SOLUTIONS

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Issues with Webhook JSON Parsing & Token Handling in Marketo

You don't add any quotes at all. You set the Request Encoding to JSON. That's what encoding means: the token values are automatically encoded based on the field type.

View solution in original post

dtavangar
Level 2

Re: Issues with Webhook JSON Parsing & Token Handling in Marketo

This is annoying! I had Request Token Encoding set to none for some reason! now it's working! Thank you Brother I appreciate you

 

View solution in original post

3 REPLIES 3
SanfordWhiteman
Level 10 - Community Moderator

Re: Issues with Webhook JSON Parsing & Token Handling in Marketo

You don't add any quotes at all. You set the Request Encoding to JSON. That's what encoding means: the token values are automatically encoded based on the field type.
dtavangar
Level 2

Re: Issues with Webhook JSON Parsing & Token Handling in Marketo

This is annoying! I had Request Token Encoding set to none for some reason! now it's working! Thank you Brother I appreciate you

 
SanfordWhiteman
Level 10 - Community Moderator

Re: Issues with Webhook JSON Parsing & Token Handling in Marketo

Great!