Hello,
We are using Marketo API to create leads in bulk. We got a situation where we are not able store a string with double quotes in it.
Example: FullName = David "Graham"
In above example "Graham" is in double quotes. So, Marketo API throws invalid JSON format error. Could you please help me in handling this issue?
Thank you!
Is there any reason why you couldn't just escape the character a la David \"Graham\" Cracker?
Yes, this is how input goes to API in JSON format. But no luck.
JSON escaped quotes is an industry-standard format (an RFC, in fact) and will work fine against the REST Leads endpoint, no need for any webhook workaround!
Please provide the full JSON of your request as it goes on the wire to Marketo. If you use Postman you'll see a properly-formatted JSON payload works fine.
Thanks, Sanford. I have figured out the root cause. We were actually storing JSON format in a C# string before passing in API which was converting \" as ". We did correct it now so that \" will be passed to API instead double quotes(").
Thanks again for the detailed explanation which was helpful.
OK, please mark Courtney's answer as Correct.
Workaround:
Webhook to php file with XML responses
Replace " with some other character like |. Have a smart campaign listening on data value change and new value contains | > call webhook
* Note to set XML webhook response type to XML
You're php code would be:
<?php
$fn = $_POST['fn'];
$ln = $_POST['ln'];
$fn = preg_replace('/\|/', '"', $fn);
$ln = preg_replace('/\|/', '"', $ln);
header("Content-type: text/xml");
echo "<?xml version='1.0' encoding='UTF-8'?>";
echo "<response>";
echo "<fn>".$fn."</fn>";
echo "<ln>".$ln."</ln>";
echo "</response>";
?>