I'm using the Zoho API to insert leads into the CRM.
Everything is working fine except when one of the fields contains an ampersand, in which case the response from Zoho is this:
<?xml version="1.0" encoding="UTF-8" ?>
<response uri="/crm/private/xml/Leads/insertRecords">
<error>
<code>4835</code>
<message>Unable to parse XML data</message>
</error>
</response>
I've tried the following payloads without any success:
1/
<Leads>
<row no="1">
<FL val="Lead Owner">me@example.com</FL>
<FL val="Company">Marks & Spencer</FL>
</row>
</Leads>
2/
<Leads>
<row no="1">
<FL val="Lead Owner">me@example.com</FL>
<FL val="Company">Marks & Spencer</FL>
</row>
</Leads>
3/
<Leads>
<row no="1">
<FL val="Lead Owner">me@example.com</FL>
<FL val="Company">Marks & Spencer</FL>
</row>
</Leads>
4/
<Leads>
<row no="1">
<FL val="Lead Owner">me@example.com</FL>
<FL val="Company"><![CDATA[Marks & Spencer]]></FL>
</row>
</Leads>
I've even tested by replacing the ampersand by %26
as advised on this Zoho forum thread but with no luck.
What is the correct format to encode ampersands for Zoho queries?
Finally found a solution: strings containing a special characters must be contained in
CDATA
sections AND those special characters need to be percent encoded.So for the example above, this gives:
Note that the value
Marks%20%26%20Spencer
is also OK for the API.