Expand my Community achievements bar.

We are excited to introduce our latest innovation to enhance the Adobe Campaign user experience — the Adobe Campaign v8 Web User Interface!
SOLVED

Campaign SOAP API: How to specify greater-than ('>') or less-than ('<') in ExecuteQuery

Avatar

Level 2

Hi, I have a simple query where I'm trying to use greater-than or less-than in a query.  The documentation has multiple examples of this, such as:

<where>
  <condition expr="(@age > 15 or @age <= 45) and  (@city = 'Newton' or @city = 'Culver City') "/>
</where>

However, when I use a similar query, <condition expr="@id < 5000"/>

 I get the response:
      <SOAP-ENV:Fault>
         <faultcode>SOAP-ENV:Client</faultcode>
         <faultstring xsi:type="xsd:string">The XML SOAP message is invalid (service 'ExecuteQuery', method 'xtk:queryDef').</faultstring>
         <detail xsi:type="xsd:string"><![CDATA[(16:38) : A '<' character cannot be used in attribute 'expr', except through &lt;
...

So then I try as the error message suggests and use '&lt' instead of <

<condition expr="@id &lt 5000"/>

and I get a different error message:

 <faultstring xsi:type="xsd:string">The XML SOAP message is invalid (service 'ExecuteQuery', method 'xtk:queryDef').</faultstring>
         <detail xsi:type="xsd:string"><![CDATA[(16:40) : Unterminated entity reference, 'lt'
 

How can I specify '>' or '<' in my SOAP xml to get the API ExecuteQuery to work?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi Blair,

Symbols '<' and '>' are restricted for use in XML. Hence they need to be used in escaped form.

Try using the following where clause and it should help.

<condition expr="@id &gt; 25"/> 

or 

<condition expr="@id &lt; 5000"/>

Regards,

Vipul

View solution in original post

7 Replies

Avatar

Level 2

here is my full soap contents:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:xtk:queryDef">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:ExecuteQuery>
         <urn:sessiontoken>[deleted]</urn:sessiontoken>
         <urn:entity>
<queryDef operation="select" schema="nms:recipient" lineCount="100" >
    <select>
        <node expr="@memberKey"/>
        <node expr="@email"/>
        <node expr="@blackListEmail"/>
        <node expr="@blackList"/>
    </select>
    <where>
        <condition expr="@email like '%@%' and (@blackList = 1 or @blackListEmail = 1)"/>
        <condition expr="@id < 5000"/>
    </where>
</queryDef>
         </urn:entity>
      </urn:ExecuteQuery>
   </soapenv:Body>
</soapenv:Envelope>

Avatar

Level 2

The mystery deepens:

I just tried this query, and it works with '>'!?:

<queryDef schema="nms:recipient" operation="select" lineCount="100">   
    <select>     
      <node expr="@email"/>     
      <node expr="@lastName"/>     
      <node expr="@firstName"/>   
    </select>   
    <where>     
      <condition expr="@id > 25"/>   
    </where>   
  </queryDef>

Avatar

Level 2

Apparently, '<' does not work, but '>' does.

Therefore, a solution is to use NOT (... > ...) which will be equivalent to (... < ...)

Weird!

Avatar

Correct answer by
Employee Advisor

Hi Blair,

Symbols '<' and '>' are restricted for use in XML. Hence they need to be used in escaped form.

Try using the following where clause and it should help.

<condition expr="@id &gt; 25"/> 

or 

<condition expr="@id &lt; 5000"/>

Regards,

Vipul

Avatar

Level 10

Hi Blair,

Did you have a chance to try Vipul's answer as well? From what you mentioned in your initial question, I saw that the ";" character was missing from your condition ("&lt" instead of "&lt;".

Let us know :-)

Florent.

Avatar

Level 2

Yes, you found the issue - I didn't realize that I needed to add the semi-colon.  Thanks for the help!

Avatar

Level 2

Yes, you found the issue - I didn't realize that I needed to add the semi-colon.  Thanks for the help!