How extract the string from URI path using Regex policy which has ";" separated substrings

Not applicable

Hi,

I have a requirement in one of the assignment where I am trying to extract the the variable and it has ";" separated substrings.

e.g.

/ABC;DEF/FAQ

I want to extract the string "ABC;DEF".

I tried using the JS to extract using custom logic but proxy.pathsuffix is not accessible inside it.

Can you tell me what can be done?

0 4 1,406
4 REPLIES 4

Can you try context.getVariable("request.path") to get the path component of your URI.

@Madhan Thanks. I had tried PathSuffix but it was exposed. Let me try what you are suggesting.

@Gaurav Vishwas Joshi ,

You can use Extract variable policy to extract URI Path segment. See example below.

<ExtractVariables name="ExtractVariables-1">

   <Source>request</Source>

   <URIPath>

      <Pattern ignoreCase="true">/{pathSeg}/FAQ</Pattern>

   </URIPath>

   <VariablePrefix>urirequest</VariablePrefix>

   <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>

</ExtractVariables>

I above example urirequest.pathSeg variable will be set to ABC;DEF.

Cheers,

Anil Sagar

URI Path doen't work at all. I tried same example mentioned in apigee doc but not able to see in response.