Quick guide to applying MuleSoft's API Autodiscovery

devalexmartinez

Alex Martinez

Posted on February 16, 2024

Quick guide to applying MuleSoft's API Autodiscovery

Once you have created a Mule project and an API in API Manager, copy the API Instance ID from API Manager (8-digit number).

1. Add the API Autodiscovery Global Element

Note: You can add the API ID directly in the Global Element or as a property

Studio

In Studio, go to the Global Elements tab and click on New. Search for the Autodiscovery configuration. Add the API Instance ID from API Manager to the API ID field. Select the main flow from the dropdown.

ACB

In ACB, go to the XML view and start writing autodiscovery. Select the api-gateway:autodiscovery snippet. Add the API Instance ID from API Manager to the apiId field. Write the main flow on flowRef.

2. Find your environment's client ID/Secret

In Anypoint Platform, go to Access Management > Business Groups > select your business group > Environments > Sandbox

Note: See more ways to retrieve this info here.

Copy the Client ID and the Client Secret (click on Show)

3. Add your Anypoint Platform credentials locally

Studio

In Studio, open the Preferences and navigate to Anypoint Studio > API Manager. Under Environment Credentials, add your Client ID and Client Secret. Click on Validate > Apply and Close.

ACB

In VS Code, open the ACB tab and click the ⚙️ icon to open ACB's settings. Go to Mule > Runtime: Default Arguments and append the following arguments at the end of the string.

-M-Danypoint.platform.client_id=your_client_id -M-Danypoint.platform.client_secret=your_client_secret
Enter fullscreen mode Exit fullscreen mode

4. Add your Anypoint Platform credentials in Runtime Manager

Add your credentials to the properties tab in your Mule app deployed to Runtime Manager.

anypoint.platform.client_id=your_client_id
anypoint.platform.client_secret=your_client_secret
Enter fullscreen mode Exit fullscreen mode

Set up Gatekeeper as needed

If you keep having a 503 error code being returned, it may mean the API ID you provided is not connected to an API Manager instance. If you want to get rid of it, set up anypoint.platform.gatekeeper=disabled in your runtime variables - this will disable the connection to API Manager

a) Studio: Set it up as an environment variable in your Run Configurations
b) ACB: Set it up as an argument following the -M-D... syntax from the previous point
c) CloudHub: Set it up as a property
d) Maven: Send it as a command argument

This setting may be a security concern, make sure you discuss this with your team before setting it up or read more about it in the following resources

Other resources

💖 💪 🙅 🚩
devalexmartinez
Alex Martinez

Posted on February 16, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related