Is it possible use the regular expression on an Integer value?

We are attempting to compare the response.status.code to a regular expression and it is failing. I had assumed that Apigee would convert the Integer value to a String and then do the compare but that doesn't seem to be the case.

If we explicitly do the conversion via an AssignMessage policy and then compare the converted value to a Regular Expression it works.

My question is if this is a feature that is being added or if there is another way in which to accomplish this?

Thanks.

0 1 451
1 REPLY 1

Hi Mitchell,

I think the only way to use a Regex operator (~~ or JavaRegex) it is to manually convert the LHS to a string, as you described.

But if you're examining status.code, which is an integer, could you not use the > >= < and <= operators instead? Are you by chance checking for 4xx or 5xx?

Maybe you could just use the numeric operators directly?

https://docs.apigee.com/api-platform/reference/conditions-reference#operators

Por ejemplo

<Condition>response.status.code >= 400 and response.status.code < 500</Condition>

Addendum:

Because you are embedding the angle brackets within XML , you will need to wrap a condition like that in CDATA:

<Condition><![CDATA[response.status.code >= 400 and response.status.code < 500]]></Condition>

-Dino