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
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • 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
  • Develop a Spring Boot REST API in AWS: PART 4 (CodePipeline / CI/CD)

Trending

  • Vibe Coding With GitHub Copilot: Optimizing API Performance in Fintech Microservices
  • Mastering Advanced Aggregations in Spark SQL
  • Integrating Model Context Protocol (MCP) With Microsoft Copilot Studio AI Agents
  • Metrics at a Glance for Production Clusters
  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.4K 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

  • 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
  • Develop a Spring Boot REST API in AWS: PART 4 (CodePipeline / CI/CD)

Partner Resources

×

Comments
Oops! Something Went Wrong

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

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

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 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!