Apigee Environment: Cloud
Problem Description:
I was attempting to modify the regular expression on a Condition that was included in the OOTB SOAP pass thru proxy and was unable to use a regular expression that contained a match on the double quote (") character. Whenever I attempted to save the regular expression (which was validated using the Java run time) Apigee would display the following error:
Error in proxy default. Invalid condition: !((request.header.Content-Type ~~ "(text|application)\/(xml|([a-z]*\+xml))(;(\w)*=(\S*))?") or (request.header.Content-Type ~~ "(multipart\/related)[;[ ]*[\w]+=[\S]+]*(;[ ]*type="application\/xop\+xml")[;[ ]*[\w]+=[\S]+]*")) and (request.verb != "GET") in policy Invalid-SOAP. Reason: Unmatched closing ) near index 224
Failing condition:
The condition below caused the failure message shown above in Apigee.
<Condition>!((request.header.Content-Type ~~ "(text|application)\/(xml|([a-z]*\+xml))(;(\w)*=(\S*))?") or (request.header.Content-Type ~~ "(multipart\/related)[;[ ]*[\w]+=[\S]+]*(;[ ]*type="application\/xop\+xml")[;[ ]*[\w]+=[\S]+]*")) and (request.verb != "GET")</Condition>
Working condition:
The condition below worked around the issue and allowed me to successfully save the proxy changes.
<Condition>!((request.header.Content-Type ~~ "(text|application)\/(xml|([a-z]*\+xml))(;(\w)*=(\S*))?") or (request.header.Content-Type ~~ "(multipart\/related)[;[ ]*[\w]+=[\S]+]*(;[ ]*type=(.{1})application\/xop\+xml(.{1}))[;[ ]*[\w]+=[\S]+]*")) and (request.verb != "GET")</Condition>
Is there a way to escape double quote (") characters in regular expressions? I couldn't find the answer looking at the regular expression and/or condition documentation.
Solved! Go to Solution.
Using unicode to specify the rabbit ears works for me. Here's my simple test case.
request.header.Content-Type ~~ "(multipart\/related)(; *type=\u0022application\/xop\+xml\u0022)"
If I pass in
-H 'content-type:multipart/related; type="application/xop+xml"'
...then the condition evaluates to true.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |