API Manager – Auto-Discovery
API auto-discovery is a mechanism that manages an API from API Manager by pairing the deployed application to an API created on the platform.
In this use case we will deploy the application through Anypoint Studio
First update the AnyPoint Studio with Anypoint Platform credentials –same credential will be used to deploy your code in CloudHub.
Add the credential – Goto Window – Preferences – Anypoint Studio – Authentication
Now update organization Client id and secret in AnyPoint Studio
We need to get the credentials from AnyPoint platform – in case you can’t see the option then check with Administrator.
Click on organization name and then copy Client id and Secret
Update the same in AnyPoint Studio and validate it.
Now we need to create the API Manager configuration for the application.
In API Manager – create the API Manager configuration for the mule application – API name will be synced with Exchange assets.
Once saved you can see the API ID under Autodiscovery – please note it down. Also, see the status right now is Unregistered.
Now in mule application we must add the AutoDiscovery configuration – add the Global Elements -> AutoDiscovery -> APP ID which we had noted down in earlier step
Now deploy the application through AnyPoint Studio only – as this will ensure the client id and secret will be pushed from Anypoint Studio to Cloudhub.
Or if we want to deploy the mulesoft application manually or through Maven then please add below properties in your deployment
Under properties tab
anypoint.platform.analytics_base_uri=https://analytics-ingest.anypoint.mulesoft.com/ anypoint.platform.client_id=2ccab1a7dcd94b69b7b1aa93c40af931 anypoint.platform.client_secret=C30fE68A87464438B534eFC47e4da0fB anypoint.platform.base_uri=https://anypoint.mulesoft.com/
Once deployed we can see the application in Mule runtime and logs confirming that its successfully got registered with API manager.
Also, we can access the endpoint now –
Now if we check API manager again then it’s status must change to Active as application is now registered.
Now attach the client policy in API manager for this application
Select credential origin
Click Apply
Now if we hit the same endpoint then we must get authentication error –
Now let’s create client application credential for accessing the application – from Exchange request for the access.
If no SLA tier is defined, then it will take to Client App page
Just note down the client id and secret
Now if we pass this client id and secret then we can access the application.
need small help in mulesoft dtawave,If you do not mind can you lease share your number?
Please post your queries to [email protected]
Nicely put, Thank you.
Hi, I tried the same approach but still my API manager is in unrigestered state.
do we need to add traits in the API spec before build it in anypoint studio.
No, traits is not required, please check if you are passing client id/secret of your organization while deployment and if you have selected the correct autodiscovery id.
Hello, Can somebody throw some light on the following error in the runtime manager. I am trying API autodiscovery. I have got client_id/client_secret in the properties and I see the following msg in the log as well: “Client ID and Client Secret successfully validated against API Manager.” I have disabled gatekeeper due to a different error and Mule runtime v 4.2.1. The app is started successfully but the API status is still Unregistered. I see the following error frequently. Failed to retrieve API information for API ‘12345678’. This request will be retried after some backoff time. Reason: com.mulesoft.mule.runtime.gw.client.exception.HttpResponseException: Server returned wrong… Read more »
Hi Uresh,
Looks like API ID 12345678 is incorrect or you are using dummy value. please get the API ID under Autodiscovery from API manager.
Keep learning!
Thanks,
Mulesy Team
Thanks for responding.
Here is the actual error message with the actual autodiscovery id. Also, I set the client_id and client_secret in the properties.
Failed to retrieve API information for API ‘16282398’. This request will be retried after some backoff time. Reason: com.mulesoft.mule.runtime.gw.client.exception.HttpResponseException: Server returned wrong status code: 403. Details: Forbidden
please see below link –
https://help.mulesoft.com/s/article/Application-fails-to-retrieve-policies-from-Exchange-with-error-code-403
also, are you deploying your code on cloudhub or on-premise system?
Is there any way to use a dummy value for testing purposes in Local environment ?
If there is no SLA based policy will the API Manager approves the request by default ?
I think yes, How to avoid this By forcing the user to select anyone SLA policy ?
is it possible to automate the policy creation, get theAPIid and pass it to the API automated CICD process ?
appid is not getting activated in API Manager in on-premise server. Already added above 4 parameters in property file but still showing not active. I am passing correct org client credential.
Properties should be passed in properties tab in runtime manager. Also the client id and secret for each environment will be different.