skumarcse
skumarcse

Reputation: 169

How to retrieve HTTP REST METHOD of current service at Run time in WSO2 AM Sequence?

How to retrieve HTTP REST METHOD(GET,PUT,POST,DELETE,OPTIONS) in WSO2 Api Manager's Sequence at runtime? I tried to $ctx:REST_METHOD which returns 'null' value.

  <sequence name="ec_rest_dynamic_ep" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
  <property expression="$ctx:REST_METHOD" name="restmethod"
    scope="default" type="STRING"/>
  <log>
    <property expression="get-property('restmethod')" name="*******************REST_METHOD***********"/>
  </log>
</sequence>

Basically, HTTP REST METHOD value of current service & URL context of that service needed to identify the service in order redirect the service to its endpoint dynamically at runtime.

Upvotes: 1

Views: 1918

Answers (2)

Bee
Bee

Reputation: 12512

@Pubci's answer is correct. Here is another way.

<property name="Method" scope="transport" expression="$ctx:api.ut.HTTP_METHOD"/> 

Some other properties can be found here.

Upvotes: 0

Pubci
Pubci

Reputation: 4001

Try the following property.

<property name="Http_Method" expression="get-property('axis2', 'HTTP_METHOD')"/>

You can find more useful properties in [1].

Upvotes: 2

Related Questions