How to extract {id} from /{id} by message assign policy

Can I obtain 12345 from http://api.example.com/weather/12345 by message assign policy? I can get /12345 as a {proxy.pathsuffix} variable. However it contains "/" that I want to remove.

Solved Solved
0 2 625
1 ACCEPTED SOLUTION

Dear @Sokichi Fujita ,

Ideally, You need to use extract variables policy to extract the id from URL instead of Assign Message policy.

<ExtractVariables name="ExtractVariables-1">
   <Source>request</Source>
   <URIPath>
      <Pattern ignoreCase="true">/weather/{id}</Pattern>
   </URIPath>
   <VariablePrefix>urirequest</VariablePrefix>
   <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</ExtractVariables>

In above example, the urirequest.id variable is set to whatever appears in the URI path after "/weather/".

View solution in original post

2 REPLIES 2

Dear @Sokichi Fujita ,

Ideally, You need to use extract variables policy to extract the id from URL instead of Assign Message policy.

<ExtractVariables name="ExtractVariables-1">
   <Source>request</Source>
   <URIPath>
      <Pattern ignoreCase="true">/weather/{id}</Pattern>
   </URIPath>
   <VariablePrefix>urirequest</VariablePrefix>
   <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</ExtractVariables>

In above example, the urirequest.id variable is set to whatever appears in the URI path after "/weather/".

Hi @Anil Sager,

Thank you. I could get the {id] by using extract variables policy.