DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • GraphQL vs REST API: Which Is Better for Your Project in 2025?
  • Update User Details in API Test Client Using REST Assured [Video]
  • Create User API Test Client With REST Assured [Video]
  • How to Make a REST API Call in Angular

Trending

  • Rethinking Java CRUDs With Event Sourcing and CQRS Patterns
  • Microservices: Externalized Configuration
  • How to Parse Large XML Files in PHP Without Running Out of Memory
  • Spring AI Advisors: Chat Memory, Token Tracking, and Message Logging
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Using REST APIs [WSO2 API Manager]

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.

By 
Anupam Gogoi user avatar
Anupam Gogoi
·
Oct. 29, 18 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
17.6K Views

Join the DZone community and get the full member experience.

Join For Free

Introduction

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
{
  "callbackUrl": "www.google.com",
  "clientName": "rest_api_publisher",
  "owner": "admin",
  "grantType": "password refresh_token",
  "saasApp": true
}


Response
{
    "clientId": "VapXbCr9XKTZJK3t_VNDtK5X2Ksa",
    "clientName": "admin_rest_api_publisher",
    "callBackURL": "www.google.lk",
    "clientSecret": "AA2b35yIOrqKzfxZVCxJ5OZH0Rwa",
    "isSaasApplication": true,
    "appOwner": null,
    "jsonString": "{\"grant_types\":\"password refresh_token\"}",
    "jsonAppAttribute": "{}",
    "tokenType": null
}


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
{
    "access_token": "f6e21049-8f0f-3c05-b337-5f34b5fd4ea0",
    "refresh_token": "a7d60f0b-7360-3b11-92de-e8b4ffb26ea0",
    "scope": "apim:api_create",
    "token_type": "Bearer",
    "expires_in": 3600
}


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
{
  "previous": "",
  "list": [
    {
      "provider": "admin",
      "version": "1.0.0",
      "description": "This sample API provides Account Status Validation",
      "name": "AccountVal",
      "context": "/account",
      "id": "2e81f147-c8a8-4f68-b4f0-69e0e7510b01",
      "status": "PUBLISHED"
    },
    {
      "provider": "admin",
      "version": "1.0.0",
      "description": null,
      "name": "api1",
      "context": "/api1",
      "id": "3e22d2fb-277a-4e9e-8c7e-1c0f7f73960e",
      "status": "PUBLISHED"
    }
  ],
  "next": "",
  "count": 2
}


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.

API REST Web Protocols

Opinions expressed by DZone contributors are their own.

Related

  • GraphQL vs REST API: Which Is Better for Your Project in 2025?
  • Update User Details in API Test Client Using REST Assured [Video]
  • Create User API Test Client With REST Assured [Video]
  • How to Make a REST API Call in Angular

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook