Re: How to handle Double Quotes using Marketo API?

Anonymous
Not applicable

How to handle Double Quotes using Marketo API?

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!

6 REPLIES 6
Casey_Grimes
Level 10

Re: How to handle Double Quotes using Marketo API?

Is there any reason why you couldn't just escape the character a la David \"Graham\" Cracker?

Anonymous
Not applicable

Re: How to handle Double Quotes using Marketo API?

Yes, this is how input goes to API in JSON format. But no luck.

SanfordWhiteman
Level 10 - Community Moderator

Re: How to handle Double Quotes using Marketo API?

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.

pastedImage_0.png

pastedImage_1.png

pastedImage_0.png

Anonymous
Not applicable

Re: How to handle Double Quotes using Marketo API?

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.

SanfordWhiteman
Level 10 - Community Moderator

Re: How to handle Double Quotes using Marketo API?

OK, please mark Courtney's answer as Correct.

Jay_Jiang
Level 10

Re: How to handle Double Quotes using Marketo API?

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

pastedImage_2.png

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>";

?>