user2789361
user2789361

Reputation: 91

URI templates in WSO2 API Publisher

Is it possible to register endpoints with URI templates in the API Publisher that ships with WSO2 API Manager version 1.4.0? For example, I would like to register an endpoint such as:

/jobs/{jobid}/pems

After saving an API, I can see this bit in the API config file:

<resource methods="GET" url-mapping="/jobs/{jobid}/pems">

I have tried manually changing the XML file from url-mapping to uri-template, i.e., to:

<resource methods="GET" uri-template="/jobs/{jobid}/pems">

but I still get "No matching resource found in the API for the given request". In any case, this is not a good work around since we need developers to be able to register these endpoints from the publisher application. Whenever changes are saved to an API from within the API Publisher interface, 'uri-template' gets reverted back to 'url-mapping'.

Thanks in advance.

Upvotes: 2

Views: 1926

Answers (3)

lalaji Sureshika
lalaji Sureshika

Reputation: 514

I would like to add some more points.As I mentioned earlier,WSO2 APIManager supports uri-templates.Only api-publisher app UI is not allowing to add uri-templates.
When creating the API from the Publisher UI, you have to give the resource mapping as /* or valid url-mapping. Then when the synapse api is created, you have to change that xml file to uri-template and then change the /* to the uri-template pattern.

Hope above will help you to resolve your issue.

Thanks;

Upvotes: 0

Ratha
Ratha

Reputation: 9702

we don't currently support uri-template patterns. We support only url-mappings.
Even , if you edit the backend API configuration (that is, api configuration file ) to url-mappings, it wont work, because we validate request before the request get hits the mediation engine.

You can use ESB RESTApi as your backend service endpoint.That is, define the RESTAPI in wso2esb, with uri-templates(it is supported out of the in ESB) and point that API as the service endpoint from wso2APIManager with url-mappings pattern.

Upvotes: 0

lalaji Sureshika
lalaji Sureshika

Reputation: 514

This is due to APIPublisher app only supports URL-Mappings when defining API resources.

If you want to define a uri-template ,instead of a url-mapping,you can achieve this from changing the api xml manually.

But before that make sure,when creating the API,you have define the API with a valid url-mapping.So in your trying API,first please edit the API from APIPublisher as keeping a valid url-mapping pattern for API resources and then change its xml to match with your mentioned uri-template pattern.

Thanks;

Upvotes: 2

Related Questions