本文介绍了Zoho API 中 XML 中的 & 符号错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Zoho API 将潜在客户插入 CRM.

I'm using the Zoho API to insert leads into the CRM.

一切正常,除非其中一个字段包含与号,在这种情况下,Zoho 的响应是这样的:

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">[email protected]</FL>
        <FL val="Company">Marks & Spencer</FL>
    </row>
</Leads>

2/

<Leads>
    <row no="1">
        <FL val="Lead Owner">[email protected]</FL>
        <FL val="Company">Marks &amp; Spencer</FL>
    </row>
</Leads>

3/

<Leads>
    <row no="1">
        <FL val="Lead Owner">[email protected]</FL>
        <FL val="Company">Marks &#038; Spencer</FL>
    </row>
</Leads>

4/

<Leads>
    <row no="1">
        <FL val="Lead Owner">[email protected]</FL>
        <FL val="Company"><![CDATA[Marks &amp; 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.

为 Zoho 查询编码与号的正确格式是什么?

What is the correct format to encode ampersands for Zoho queries?

推荐答案

终于找到了解决方案:包含特殊字符的字符串必须包含在 CDATA 部分 AND 那些特殊的字符需要百分比编码.

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:

<Leads>
    <row no="1">
        <FL val="Lead Owner">[email protected]</FL>
        <FL val="Company"><![CDATA[Marks %26 Spencer]]></FL>
    </row>
</Leads>

请注意,值 Marks%20%26%20Spencer 也适用于 API.

Note that the value Marks%20%26%20Spencer is also OK for the API.

这篇关于Zoho API 中 XML 中的 & 符号错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 08:24