Tuesday, November 25, 2014

What is the best way to create an API in wso2 API-Manager 1.7.0

There was an issue with API improvements from 1.6.0 to 1.7.0 in multiple resource creation. Please apply attached PATCH-0580 to fix the issue.

 

Follow below mentioned guide to create multiple resources

 

1. To create multiple resources for a single uri-template (for multiple resource methods) refer below sample

 

ADD API:

 

curl -X POST -b cookies http://localhost:9763/publisher/site/blocks/item-add/ajax/add.jag -d "action=addAPI&name=Twitter&visibility=public&version=1.0.0&description=API for twitter&endpointType=nonsecured&http_checked=http&https_checked=https&tags=tweet,test&tier=Bronze&thumbUrl=https://g.twimg.com/Twitter_logo_blue.png&context=/tweet&tiersCollection=Bronze,Gold,Unlimited&resourceCount=0&resourceMethod-0=GET,PUT,POST,DELETE&resourceMethodAuthType-0=Application,Application,Application,Application&uriTemplate-0=/test/*&resourceMethodThrottlingTier-0=Bronze, Bronze,Unlimited,Gold" -d 'endpoint_config={"production_endpoints":{"url":"http://search.twitter.com","config":null},"endpoint_type":"http"}'

 

UPDATE API:

 

curl -X POST -b cookies http://localhost:9763/publisher/site/blocks/item-add/ajax/add.jag -d "action=updateAPI&name=Twitter&provider=provider&visibility=public&version=1.0.0&description=API for twitter changed&endpointType=nonsecured&http_checked=http&https_checked=https&tags=tweet,test&tier=Bronze&thumbUrl=https://g.twimg.com/Twitter_logo_blue.png&context=/tweet&tiersCollection=Bronze,Gold,Unlimited&resourceCount=0&resourceMethod-0=GET,PUT,POST&resourceMethodAuthType-0=Application,Application,Application&uriTemplate-0=/test/*&resourceMethodThrottlingTier-0=Gold,Gold,Gold" -d 'endpoint_config={"production_endpoints":{"url":"http://search.twitter.com","config":null},"endpoint_type":"http"}'

 

 

2. To create multiple resources with multiple uri-templates refer below sample

 

curl -X POST -b cookies http://localhost:9763/publisher/site/blocks/item-add/ajax/add.jag -d "action=addAPI&name=Twitter&visibility=public&version=1.0.0&description=API for twitter&endpointType=nonsecured&http_checked=http&https_checked=https&tags=tweet,test&tier=Bronze&thumbUrl=https://g.twimg.com/Twitter_logo_blue.png&context=/tweet&tiersCollection=Bronze,Gold,Unlimited&resourceCount=2&resourceMethod-0=GET,PUT,POST,DELETE&resourceMethodAuthType-0=Application,Application,Application,Application&uriTemplate-0=/test/*&resourceMethodThrottlingTier-0=Bronze,Bronze,Unlimited,Gold&resourceMethod-1=GET,PUT&resourceMethodAuthType-1=Application User,Application User&uriTemplate-1=/test2/*&resourceMethodThrottlingTier-1=Unlimited,Unlimited" -d 'endpoint_config={"production_endpoints":{"url":"http://search.twitter.com","config":null},"endpoint_type":"http"}'

 

*NOTE : in this case follow following convention

resourceCount=[number of resources]

 

and for each resource parameters

[resource parameter]-[resource number 0,1,...]=[value]

example:

resourceMethod-1=GET

esourceMethodAuthType-1=Application .... etc.

 

Following configurations are also provided to manage api

default_version_checked, wsdl, wadl, inSequence, outSequence, faultSequence, responseCache, cacheTimeout, subscriptions, tenants,.. etc.


Thanks & Regards,

Rajakrishna Reddy,

 

No comments:

Post a Comment