IBM Support

How to consume Consumer APIs provided by API Connect Platform

How To


Summary

This article describes how to consume the API Connect Consumer APIs that is provided by the platform.

The API Connect Platform REST APIs provide complete access to the capability of the platform. Consumer APIs can be used to automate administration of consumer side of the platform, for example consumer orgs, users, app registrations and so on.

Objective

  1. Register a client app with API Connect Cloud.
  2. Consume API Connect Consumer API provided by API Connect Platform.

Steps

Prerequisites:
  1. API Connect toolkit is installed. 
  2. Postman application is installed and working knowledge of Postman to perform tests.
  3. You need to have cloud admin level access to register a client app with the API Connect Cloud.
Register client app with API Connect Cloud
Step 1. Register an app with api connect cloud in 'consumer_toolkit' scope and get client id and client secret. See the following article for instructions:
Find Consumer API endpoint
Step 2.  Find value of 'Platform REST API endpoint for consumer APIs' from APIC Cloud Manager.
Log in to Cloud Manager UI. Go to Settings->Endpoints.
image 2436
Copy the value from "Platform REST API endpoint for consumer APIs", you will need it in next steps.
Consume API Connect Consumer APIs
Step 3.  Invoke the POST method on the token endpoint to get a bearer token.
In this step, you invoke the POST method on token endpoint. As shown in the example, construct the token endpoint, request headers and request body.
Token Endpoint:
<<Platform REST API endpoint for consumer APIs>>/token
Request Headers:
Content-Type:application/json
Accept:application/json
X-IBM-Consumer-Context:<<provider-org>>.<<catalog>>
Request Body:
{
    "username": "<< developer portal username>>",
    "password": "<<password>>",
    "realm": "consumer:<<provider-org>>:<<catalog>>/<<catalog>>-idp",
    "client_id": "<<app client id from step 1>>",
    "client_secret": "<<app client secret from step 1>>",
    "grant_type": "password"
}
Send the request using Postman as shown in the example screen shot, you get a token.
image 2437
Copy the value of "access_token" from the response. You will need it in the next step.
Step 4. Invoke a Consumer API  endpoint - /orgs
Try invoking any one of the API Connect Consumer APIs, in this example I selected /orgs.
You can construct request endpoint and headers, for example:
Note: You can find all available Consumer APIs on the link "API Connect Platform REST API Reference" in Related Information section at the bottom of this article.
Platform API Endpoint:
<<Platform REST API endpoint for admin and provider APIs>>/orgs
Request Method: GET
Request Headers:
Accept:application/json
Authorization:Bearer <<access-token-from-previous-step>>
X-IBM-Consumer-Context:<<provider-org>>.<<catalog>>
Send the request using Postman as shown in the sample screen shot. You get a list of consumer organizations in the response.
image 2438
You successfully invoked the Consumer API provided by the API Connect Platform.
You can find a Postman collection for this example in the file -  APIC Consumer API Example.postman_collection.zip.
Note: You need to adjust parameter values to match your environment.

Document Location

Worldwide

[{"Type":"MASTER","Line of Business":{"code":"LOB45","label":"Automation"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSMNED","label":"IBM API Connect"},"ARM Category":[{"code":"a8m50000000Ce96AAC","label":"API Connect->Developer (DV)"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"2018.4.1.0;and future releases"}]

Document Information

Modified date:
02 August 2021

UID

ibm13554139