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?
1 Like
@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
2 Likes
You can find similar examples in the doc on ExtractVariables here.
Stephen
How to extract multiple variable from same url?
/store/{storeId}/location/{location}
i want to use the javascript policy, can any one of you please guide me how to retrive with javascript policy