Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How can we extract dynamic parts from the URI path ?

We have the base path for a Proxy which has some dynamic parts (wild card characters) in it:

<BasePath>/dev/v1/ships/*/sailDate/*/enhanced</BasePath>

Let’s say we make a API call with the URL as follows:

curl -v https://org-env.apigee.net/dev/v1/ships/10045/sailDate/22Sep/enhanced

We would like to extract the values passed to the dynamic variables (wild card characters) of the base path/URI and use in a Service Callout Policy. We created the following Extract Variables Policy as follows to extract the values from the URI:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-URI-Variables"> 
   <DisplayName>Extract URI Variables</DisplayName> 
   <URIPath name="proxy.url"> 
      <Pattern ignoreCase="true">/ships/{shipCode}/sailDate/{sailDate}</Pattern>
   </URIPath> 
</ExtractVariables> 

And then we tried to use the flow variables shipCode and sailDate in the Service Callout policy

======== Service-CallOut ========

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="Service-CallOut">
  <DisplayName>Service CallOut</DisplayName>
  <Properties/>
  <Request clearPayload="true" variable="myRequest">
    <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
  </Request>
  <Response>calloutResponse</Response>
  <HTTPTargetConnection>
  <URL>http://mybackendserver/v01/ports/ships/{shipCode}/sailDate/{sailDate}</URL>
  </HTTPTargetConnection>
</ServiceCallout>

But I'm getting the following error:

{
  "fault": {
    "faultstring": "Unresolved variable : shipCode",
    "detail": {
      "errorcode": "messaging.runtime.UnresolvedVariable"
    }
  }
}

Can you please help on why am I getting this error and also help me to get the values of shipCode and sailDate ?

2 3 1,896
3 REPLIES 3