rucciva
rucciva

Reputation: 177

WSO2 API Manager change http method

Does wso2 api manager v1.10.0 permit transforming the HTTP method of the request to the backend through custom in sequence?

I created an api with http GET resource through publisher web console. But since the endpoint support POST method only, i tried changing the HTTP Method by creating custom in sequence with property mediator :

<property name="HTTP_METHOD" value="POST" scope="axis2"/>

but the response showed a fault message :

{
  "fault": {
    "code": 403,
    "type": "Status report",
    "message": "Fault Call",
    "description": "No matching resource found in the API for the given request"
  }
}

The log files only showed these lines :

==> /opt/wso2am-gateway/repository/logs/wso2carbon.log <==
[2016-04-08 10:30:16,868]  INFO -  STATUS = Executing default 'fault' sequence, ERROR_CODE = 403, ERROR_MESSAGE = No matching resource found in the API for the given request {org.apache.synapse.mediators.builtin.LogMediator}

If i remove the property mediator, the request pass through and reach the backend.

Does anyone know how to solve this problem?

Upvotes: 2

Views: 2383

Answers (2)

Ali
Ali

Reputation: 85

You can use the following custom inFlow mediation sequence to convert the HTTP_METHOD into POST from GET.

 <?xml version="1.0" encoding="UTF-8"?>
<sequence name="CustomIn" xmlns="http://ws.apache.org/ns/synapse">
    <property action="remove" name="HTTP_METHOD" scope="axis2"/>
    <property name="HTTP_METHOD" scope="axis2" type="STRING" value="POST"/>
</sequence>

Here, the request is the GET request from the client-side.

But, the above solution will be possible only when you are defining the GET and the POST resources similarly on your API (Although you don't use one of the both).

Otherwise, you will get the following error messages while you are invoking the API.

  • No matching resource found for given API Request
  • Method not allowed for given API resource
  • No matching resource found in the API for the given request

Upvotes: 2

tinnapat
tinnapat

Reputation: 356

You need to also define POST resource on your API (although you don't use it)

Upvotes: 0

Related Questions