How to handle Double Quotes using Marketo API? | Community
Skip to main content
May 30, 2018
Question

How to handle Double Quotes using Marketo API?

  • May 30, 2018
  • 2 replies
  • 3911 views

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!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Casey_Grimes2
Level 10
May 30, 2018

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

May 30, 2018

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

SanfordWhiteman
Level 10
May 31, 2018

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.

Jay_Jiang
Level 10
May 31, 2018

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

?>