Condition comparing against a string is not working as expected

I am using below condition which works if I pass cid = 123 in my request.

   <Step>
      <Name>Raise-Fault-1</Name>
     <Condition>NOT(cid=123)</Condition>
   </Step>

But when I tried passing any varchar it fails. Tried using both as below:

<Condition>NOT(cid='apigee')</Condition> 

OR

<Condition>NOT(cid=apigee)</Condition>

Is there any syntax to use this in fault policy? Please advice. Let me know how this can be achieved using Fault Policy.

Solved Solved
1 3 160
1 ACCEPTED SOLUTION

Is there any syntax to use this in fault policy?

Yes. It's not really the fault policy you're asking about. I think you're asking, what's the correct syntax to use in a Condition element?

Sadly, the thing you're running into is, the string needs to be delimited in double quotes. You used single quotes. I would prefer if Apigee would reject your Condition statement that uses single quotes, and tell you that. but today, it doesn't.

In any case, all of the following are equivalent, and any of these will work:

 <Condition>cid != "apigee"</Condition>

 <Condition>NOT(cid="apigee")</Condition>

 <Condition>NOT (cid = "apigee")</Condition>

 <Condition>cid NotEquals "apigee"</Condition>

 <Condition>NOT (cid Equals "apigee")</Condition>

View solution in original post

3 REPLIES 3

Not applicable

Can you try below.

<Condition>NOT(cid Equals "apigee")</Condition>

Or, simpler still

<Condition>cid != "apigee"</Condition>

Is there any syntax to use this in fault policy?

Yes. It's not really the fault policy you're asking about. I think you're asking, what's the correct syntax to use in a Condition element?

Sadly, the thing you're running into is, the string needs to be delimited in double quotes. You used single quotes. I would prefer if Apigee would reject your Condition statement that uses single quotes, and tell you that. but today, it doesn't.

In any case, all of the following are equivalent, and any of these will work:

 <Condition>cid != "apigee"</Condition>

 <Condition>NOT(cid="apigee")</Condition>

 <Condition>NOT (cid = "apigee")</Condition>

 <Condition>cid NotEquals "apigee"</Condition>

 <Condition>NOT (cid Equals "apigee")</Condition>