2

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?

2 Answers 2

2

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
2
  • ]t does'nt work, do you have any other ideas?
    – Mr White
    Mar 4, 2023 at 7:27
  • If it doesn’t work please explain what you have done.
    – Ali
    May 6, 2023 at 13:10
0

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

1
  • wouldn't it confuse the user of the API?
    – rucciva
    Apr 11, 2016 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.