Using REST APIs [WSO2 API Manager]
In this brief article, let's take a look at how easy it is to invoke the REST APIs of WSO2 API Manager.
Join the DZone community and get the full member experience.
Join For FreeIntroduction
The WSO2 API Manager exposes a series of REST APIs and they are quite useful if you are going to create custom tools, solutions, for example, a Maven plugin. In this article, I'm going to explain how to use the APIs and in the next series of the articles, I'm going to show how to make use of the APIs to create a Maven plugin.
Getting Started
Here is the official documentation of the REST APIs. To invoke any API, first, we need to get a pair of clientId & client secret and then use them to get the access token. Here are the necessary steps,
Get ClientID and Client Secret
Method | POST |
Headers | Authorization: Base64(username:password) |
Content-Type: application/json |
|
URL | https://localhost:9443/client-registration/v0.13/register |
Request |
|
Response |
|
Getting Access Token
Note: Access token must be generated using the correct scope. In the below example, the scope (api_view) is used to generate access token to call an API to list available APIs. To generate access token to invoke an API to create an API, one must use api_create scope.
Method | POST |
Headers | Authorization: Base64(clientId:clientSecret) |
Content-Type: application/x-www-form-urlencoded |
|
Request Params | grant_type: password |
username: admin |
|
password: admin |
|
scope : apim:api_view |
|
Response |
|
Listing APIs
Once you have the access_token in hand, the following API can be called to list available APIs.
Method | GET |
Headers | Authorization: Bearer <<ACCESS_TOKEN>> |
Response |
|
Conclusion
In this brief article, I have shown how easy it is to invoke the REST APIs of WSO2 API Manager. For more detail, please go through the official documentation of WSO2. In the follow-up article, I'm going to explain how to create a Maven plugin to publish an API using the provided REST APIs.
Opinions expressed by DZone contributors are their own.
Comments