not extracting the value from URIPATH

HI,

I am trying to use ExtractVariables to extract a segment from a URI path.

As an example, a request might use this full URL:

https://domain.com/postux/api/abchd/transactions/original-payments?companyCode=TMW&brandCode=TMW&reservationId=12857991897

The basepath of my proxy is postux

I want to extract brand (3rd segment from URIpath) as “abchd”.

We are using javascript to print the value

print(context.getVariable(“brand”)) ;

but it is not printing brand name .

Here’s the policy

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables continueOnError="false" enabled="true" name="Extract-Brand">
  <DisplayName>Extract-Brand</DisplayName>
  <Source>request</Source>
  <URIPath>
    <pattern ignoreCase="true">/api/{brand}/transactions/**</pattern>
  </URIPath>
  <!-- <VariablePrefix>urirequest1</VariablePrefix> -->
  <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</ExtractVariables>

Have you used capitalized Pattern ?

<URIPath>
    <!-- no -->
    <pattern ignoreCase="true">/api/{brand}/transactions/**</pattern>
    <!-- yes -->
    <Pattern ignoreCase="true">/api/{brand}/transactions/**</Pattern>
  </URIPath>

It’s a real shame that the validation of policy configuration sometimes does not check for valid elements.

I’ve filed a PR for apigeelint to check for this problem.

yes, i just tried. its working now. It killed my time and wasted 1 day. thanks for the solution.

1 Like

I’m sorry about that. That shouldn’t happen. I’ll see if we can get that fixed.What version of Apigee are you using?