Extract multiple segments in URIPath using ExtractVariables Pattern

Not applicable

I have a proxy in which I want to pick "rest of the url" in a variable and send it to target server. I only see examples in ExtractVariables where only one segment gets picked up. I tried it on my own but it doesn't pick multiple segments.

Example -

Incoming - /v1/myService/sdk/1.0.0/something/else/i/dont/know/about

Expected output variables -

var1 - 1.0.0

var2 - something/else/i/dont/know/about

I tried doing this -

<URIPath>
    <Pattern ignoreCase="true">/sdk/{var1}/{var2}</Pattern>
</URIPath>

I am aware I can use JavaScript policy and Regex to do this but looking for a standard way to do it, if possible. Thanks in advance.

2 1 467
1 REPLY 1

It looks like you're on the right track

I believe the URIPath pattern you used would have successfully matched if the path was

/v1/myService/sdk/1.0.0/something

For what you're trying to do, try the following

It will match the additional segments. You can find more details on this under "Using special characters in the pattern" on the Extract variables documentation

<URIPath><Pattern ignoreCase="true">/sdk/{var1}/{var2}/**</Pattern></URIPath>