Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

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

Avatar

Avatar
Validate 1
Level 1
blair_elzinga
Level 1

Likes

4 likes

Total Posts

15 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 1
blair_elzinga
Level 1

Likes

4 likes

Total Posts

15 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
blair_elzinga
Level 1

05-05-2017

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?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Employee
Vapsy
Employee

Likes

369 likes

Total Posts

726 posts

Correct Reply

342 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Validate 1
Employee
Vapsy
Employee

Likes

369 likes

Total Posts

726 posts

Correct Reply

342 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 250
View profile
Vapsy
Employee

05-05-2017

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

Answers (6)

Answers (6)

Avatar

Avatar
Validate 1
Level 1
blair_elzinga
Level 1

Likes

4 likes

Total Posts

15 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 1
blair_elzinga
Level 1

Likes

4 likes

Total Posts

15 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
blair_elzinga
Level 1

11-05-2017

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

Avatar

Avatar
Validate 1
Level 1
blair_elzinga
Level 1

Likes

4 likes

Total Posts

15 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 1
blair_elzinga
Level 1

Likes

4 likes

Total Posts

15 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
blair_elzinga
Level 1

11-05-2017

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

Avatar

Avatar
Give Back 50
Level 10
florentlb
Level 10

Likes

237 likes

Total Posts

1,109 posts

Correct Reply

239 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 200
View profile

Avatar
Give Back 50
Level 10
florentlb
Level 10

Likes

237 likes

Total Posts

1,109 posts

Correct Reply

239 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 200
View profile
florentlb
Level 10

10-05-2017

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

Avatar
Validate 1
Level 1
blair_elzinga
Level 1

Likes

4 likes

Total Posts

15 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 1
blair_elzinga
Level 1

Likes

4 likes

Total Posts

15 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
blair_elzinga
Level 1

05-05-2017

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

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

Weird!

Avatar

Avatar
Validate 1
Level 1
blair_elzinga
Level 1

Likes

4 likes

Total Posts

15 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 1
blair_elzinga
Level 1

Likes

4 likes

Total Posts

15 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
blair_elzinga
Level 1

05-05-2017

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

Avatar
Validate 1
Level 1
blair_elzinga
Level 1

Likes

4 likes

Total Posts

15 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 1
blair_elzinga
Level 1

Likes

4 likes

Total Posts

15 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
blair_elzinga
Level 1

05-05-2017

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>