Monday, August 03, 2015

Updating wso2 APIManager APIs with Publisher APIs

Here i'll show how to add and update apis to wso2 api manager using publisher-apis(1)


1. Login and get cookie
curl -X POST -c cookies http://localhost:9763/publisher/site/blocks/user/login/ajax/login.jag -d 'action=login&username=admin&password=admin'


2. Add API
curl -X POST -b cookies http://localhost:9763/publisher/site/blocks/item-add/ajax/add.jag -d "action=addAPI&name=YoutubeFeeds&visibility=public&version=1.0.0&description=Youtube Live Feeds&endpointType=nonsecured&http_checked=http&https_checked=https&&wsdl=&tags=youtube,gdata,multimedia&tier=Silver&thumbUrl=http://www.10bigideas.com.au/www/573/files/pf-thumbnail-youtube_logo.jpg&context=/youtube&tiersCollection=Gold&resourceCount=0&resourceMethod-0=GET&resourceMethodAuthType-0=Application&resourceMethodThrottlingTier-0=Unlimited&uriTemplate-0=/*" -d'endpoint_config={"production_endpoints":
{"url":"http://gdata.youtube.com/feeds/api/standardfeeds","config":null}
,"endpoint_type":"http"}';


3. Update API with a new resource(POST) called "/postTest"
curl -X POST -b cookies http://localhost:9763/publisher/site/blocks/item-add/ajax/add.jag -d "action=updateAPI&name=YoutubeFeeds&visibility=public&version=1.0.0&description=Youtube Live Feeds&endpointType=nonsecured&http_checked=http&https_checked=https&&wsdl=&tags=youtube,gdata,multimedia&tier=Silver&thumbUrl=http://www.10bigideas.com.au/www/573/files/pf-thumbnail-youtube_logo.jpg&context=/youtube&tiersCollection=Gold&resourceCount=2&resourceMethod-0=GET&resourceMethodAuthType-0=Application&resourceMethodThrottlingTier-0=Unlimited&uriTemplate-0=/*&resourceMethod-1=POST&resourceMethodAuthType-1=Application&resourceMethodThrottlingTier-1=Unlimited&uriTemplate-1=/postTest" -d'endpoint_config={"production_endpoints":
{"url":"http://gdata.youtube.com/feeds/api/standardfeeds","config":null}
,"endpoint_type":"http"}';


4. Add two more methods PUT and GET for the same "/postTest" resource
curl -X POST -b cookies http://localhost:9763/publisher/site/blocks/item-add/ajax/add.jag -d "action=updateAPI&name=YoutubeFeeds&visibility=public&version=1.0.0&description=Youtube Live Feeds&endpointType=nonsecured&http_checked=http&https_checked=https&&wsdl=&tags=youtube,gdata,multimedia&tier=Silver&thumbUrl=http://www.10bigideas.com.au/www/573/files/pf-thumbnail-youtube_logo.jpg&context=/youtube&tiersCollection=Gold&resourceCount=4&resourceMethod-0=GET&resourceMethodAuthType-0=Application&resourceMethodThrottlingTier-0=Unlimited&uriTemplate-0=/*&resourceMethod-1=POST&resourceMethodAuthType-1=Application&resourceMethodThrottlingTier-1=Unlimited&uriTemplate-1=/postTest&resourceMethod-2=PUT&resourceMethodAuthType-2=Application&resourceMethodThrottlingTier-2=Unlimited&uriTemplate-2=/postTest&resourceMethod-3=GET&resourceMethodAuthType-3=Application&resourceMethodThrottlingTier-3=Unlimited&uriTemplate-3=/postTest" -d'endpoint_config={"production_endpoints":
{"url":"http://gdata.youtube.com/feeds/api/standardfeeds","config":null}
,"endpoint_type":"http"}';


Note that here we use the zero based indexes. Also note that resourceMethod can take any one of the following values: GET, POST, DELETE, PUT, OPTIONS - (1)

(1) - https://docs.wso2.com/display/AM180/Publisher+APIs