webMethods API Portal tutorial
API-driven automation helps to replace human involvement in a complex and monotonous, repetitive tasks. It involves replacing human intervention with calls to an API. In other words, rather than have a person execute that task, we tell a system to do it instead.
In this tutorial we will explore the possibilities of automating API publishing related activities within webMethods API Portal. As part of this tutorial we will be mainly using Curl commands to invoke the APIs. If you are unfamiliar with Curl you can check the basic tutorial here https://curl.haxx.se/docs/httpscripting.html first.
Creating an API
We can publish API to API Portal in two ways. You could use the swagger/raml/wsdl files available locally on your machine to publish it to API Portal. Or you can import the definitions from a remote URL.
- Create API from local file
We can use below Curl command to publish an API definition into API Portal.
-u parameter dictates the user to be used for the publishing. Please make sure the provided user have the role of API Administrator/API Provider
The publishing API(abs/apirepository/v1/apis) takes type as one of the query parameter. Valid values are swagger/raml/wsdl
The form parameter ('api-package') should point to the accessible location of the swagger/raml file. For example if the file is located in /tmp/source then we should provide the value as '@/tmp/source/calculator.json'
- Create API from remote URL
We can use below Curl command to publish an API definition from a remote URL into API Portal.
If the creation is succesful, above invocation will provide a response something similar to below text.
We can use below API Portal API to list the published API definitions.
The response includes the GUID of the published API , name, and short description.
Updating an API definition
We can republish API similar to the ways we created them. The endpoint for updating the API would include the GUID of the API being updated abs/apirepository/v1/apis/<<GUID>>
Associating the API to a community
Often times customers would like to associate specific APIs to specific communities. Inorder to associate an API to a community we must know the community identifier to which we are going to associate this API.
To list the communities
We can use below Curl command to list the communities registered in API Portal.
response includes the GUID of the community, name and its short description.
Now to associate an API to a Community, we have to know the GUID of the API and GUID of the community. We can use below Curl command to associate an API to community.
Now we have included 'Calculator API' into 'Private Community'
Sometimes we need to cleanup some of the obsolete items. We can use below API to remove an unwanted API definition from API Portal.
API consumes GUID of the published API definition as its path parameter. GUID of the API can be retried from the list API we seen in the past.