I recently had to setup Anypoint Studio on a new machine to continue developing Mule APIs. Quite quickly I hit an issue when running an API locally I wouldn’t get any response or messages in the logs when the API was called. This is a problem I have had other Mule developers (especially those newer to MuleSoft) ask previously how to resolve so I have decided to write up the explanation.
You have created the API Specification in Design Centre.
Published it to Exchange.
Created it in API Manager to be managed.
Imported it to Anypoint Studio to be developed.
Added Auto-Discovery code to link it to API Manager.
You go to run it locally in Anypoint Studio and it appears to succesfully deploy but when you call it you get no response and nothing new appears in the logs. After some hunting you find the following error in the logs during deployment:
The API Manager also does not mark the API as Active to show the implementation is running and connected.
The issue occurs as the embedded Mule runtime (in Anypoint Studio) is not authenticated with the Anypoint Platform so although it has the API ID that is not enough to connect to the API Manager. This prevents a third party from registering a Mule App against your API in the API Manager (e.g. if they mistyped the ID).
To resolve this in Anypoint Studio go to Window -> Preferences -> Anypoint Studio -> API Manager.
You will see two fields that you need to populate; Client ID & Client Secret.
These fields need to be populated with either Organisation Credentials or Business Group Credentials.
These can be obtained by going to Anypoint Platform -> Management Center -> Access Management -> Organization.
Click the Business Group or Organization name that the API has been created in.
Copy the Client Id & Client Secret into the configuration in Anypoint Studio.
Alternatively, the credentials can also be picked up from the Environments tab in Access Management. If you don’t have access to Access Management you will need to request these credentials from your Platform Admin.
Click Validate and ensure the green tick appears confirming the credentials are correct. Re-run the Mule App and the error should no longer appear and you will be able to call the API and get a response.
CloudHub & Runtime Manager
Apps deployed to CloudHub or on-premise will also need the above Client ID & Secret set as properties. The properties to set are:
Hope this helps, more information on this can be found here.