{{announcement.body}}
{{announcement.title}}

Web UI to Create Client App and Contract to Access an API in API Manager (Mule 4)

DZone 's Guide to

Web UI to Create Client App and Contract to Access an API in API Manager (Mule 4)

In this article, we provide a brief tutorial on how to create a client application and contract to access an API in Mule 4's API Manager.

· Integration Zone ·
Free Resource

API Manager workflow

When you create a policy in API Manager, there is need to create an application and contract between the application and the API instance. API Gateway is responsible to enforce policy based on contact created. 

Mule doesn't have a single API that can be used to create an API instance and contract. You can achieve using a sequence of call to their platform API. Click here to see the steps provided by Mulesoft knowledge base.

To make this process user friendly, you can prepare a web UI in the Mule application that would help to achieve entire steps in easy two steps.

Create a Mule Application to Build a UI-Based Web Page

  • File -> New Mule Project

Project Name : api-mule-client-contract-registratiom

Creating a new Mule project


  • Create a properties file
YAML


  • Create Mule flow as below

Creating Mule flowCreating Mule flow

Creating Mule flow

XML


Run Application

Create Anypoint Platform Token :

The token is a must to communicate to Anypoint platform API. Open URL in the browser: http://localhost:8081/token.html 

Generating Anypoint platform token

Provide your Anypoint platfrom user name and password and click on submit.

You would see the below response. This token will be needed in the next steps.

JSON


Run the application and call: GET http://localhost:8081/index.html 

Client registration form

Provide all required values, as per the above screenshot, and click on the submit button. The response should look like the following JSON payload. It means that the client and contract have created in API Manager.  

JSON


Verifying Clients and Contract in API Manager


Verifying client and contract in API Manager


Verifying client and contract in API Manager


Click here to download the source code.

Topics:
integration, mule 4 tutorial, mule api, mule security, tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}