I have a form with 4 text area fields. The content is sent to a web hook , which transfers the data to our server.
Everything works smoothly as long as I do not place a newline in the text area fields.
All form fields are put together as new value in a ‘Change Data Value’, so I construct a json string :
{"<u>GOOGLE UTM</u>": "","Source":"{{lead.mkt_cp_utm_latest_source}}","Medium":"{{lead.mkt_cp_utm_latest_medium}}","Campaign":"{{lead.mkt_cp_utm_latest_campaign}}”,”Question 1”:”{{lead.mkt_5428_xmpie_answer_1}}","Question 2”:”{{lead.mkt_5428_xmpie_answer_2}}","Question 3”:”{{lead.mkt_5428_xmpie_answer_3}}","Question 4”:”{{lead.mkt_5428_xmpie_answer_4}}"}
The content is later used in the webbook :
Is a newline breaking the json?
Is the JSON sent from the Marketo web hook according to RFC7159? 'Tabs and newline characters, unencoded, are not allowed in strings in JSON according to RFC 7159
Solved! Go to Solution.
You aren’t constructing a JSON string if the variables aren’t truly JSON-encoded. Simple as that. You’re assembling something vaguely like JSON and hoping the dynamic parts don’t require JSON encoding — not a reasonable expectation with Textarea fields, or even with Text fields for that matter (Text fields can contain double quotes).
I don’t understand why you’re trying to pre-create part of a webhook JSON payload. You should be setting Request Token Encoding=JSON and building the whole thing in the Payload box. Then Marketo correctly handles the encoding for you.
You aren’t constructing a JSON string if the variables aren’t truly JSON-encoded. Simple as that. You’re assembling something vaguely like JSON and hoping the dynamic parts don’t require JSON encoding — not a reasonable expectation with Textarea fields, or even with Text fields for that matter (Text fields can contain double quotes).
I don’t understand why you’re trying to pre-create part of a webhook JSON payload. You should be setting Request Token Encoding=JSON and building the whole thing in the Payload box. Then Marketo correctly handles the encoding for you.
Hi Sanford,
thanks for your reply.
I pre-create the json, because the content is different for multiple situations. As such I can keep re-using the same webhook.
Maybe not the best solution?
I pre-create the json, because the content is different for multiple situations. As such I can keep re-using the same webhook.
Maybe not the best solution?
I wouldn’t say so! You just can’t assemble JSON in a non-JSON-aware environment.
Is the JSON sent from the Marketo web hook according to RFC7159? 'Tabs and newline characters, unencoded, are not allowed in strings in JSON according to RFC 7159
Of course. But since you aren’t using Request Token Encoding=JSON, Marketo has no idea you’re considering this a JSON payload.