How do I extract part of the basepath to a variable
-
20-12-2019 - |
Question
I have a Proxy defined with a basepath of /v1.0/stores and a resource with a path of //address/validate*
I have an ExtractVariables policy that has
<URIPath>
<Pattern ignoreCase="false">/{storeid}/{service}/*.{format}</Pattern>
<Pattern ignoreCase="false">/{storeid}/{service}/**/*.{format}</Pattern>
</URIPath>
How do I assign the "v1.0" from the proxy.basepath to {version}?
Solution
The path being evaluated using <URIPath>
configuration is actually proxy.pathsuffix
and that contains everything after the basepath. Try this configuration in the policy:
<Variable name="proxy.basepath">
<Pattern>/{version}/**</Pattern>
</Variable>
The variable being referenced, proxy.basepath
, should be holding /v1.0/stores
. The above pattern will extract v1.0
and store it in the variable version
.
Link to Apigee variables reference which describes proxy.basepath
is located here.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow