How to extract a URI path element from an inbound request?

Not applicable

How do I extract URI path element from the request?

The need is pretty obvious, and I am sure there is a way to do it - I am just not able to find the easiest way to do it on Apigee.

I have a URI say .../dogs/1234/owners

I need to extract '1234' to query for owners. How do I go about doing it on Apigee edge?

Solved Solved
1 4 9,788
1 ACCEPTED SOLUTION

adas
New Member

@Ritwik Chatterjee Try the extract variable policy. Here's one example:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="ExtractVariablesStoreId">
    <DisplayName>ExtractVariablesStoreId</DisplayName>
    <Properties/>
    <URIPath name="storeId">
        <Pattern>**/stores/{storeId}</Pattern>
    </URIPath>
    <Source clearPayload="false">request</Source>
    <VariablePrefix>stores</VariablePrefix>
</ExtractVariables>

So if your url has /search/stores/store123 then this policy would extract the store123 value in a variable called stores.storeId

View solution in original post

4 REPLIES 4

adas
New Member

@Ritwik Chatterjee Try the extract variable policy. Here's one example:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="ExtractVariablesStoreId">
    <DisplayName>ExtractVariablesStoreId</DisplayName>
    <Properties/>
    <URIPath name="storeId">
        <Pattern>**/stores/{storeId}</Pattern>
    </URIPath>
    <Source clearPayload="false">request</Source>
    <VariablePrefix>stores</VariablePrefix>
</ExtractVariables>

So if your url has /search/stores/store123 then this policy would extract the store123 value in a variable called stores.storeId

How to extract multiple variable from same url?
/store/{storeId}/location/{location}

You can find similar examples in the doc on ExtractVariables here.

Stephen

Not applicable

i want to use the javascript policy, can any one of you please guide me how to retrive with javascript policy