cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Not able to access Rest API using on-premises controller

Pradeep.Prakasam
New Poster

Hi,

I am trying to access the REST API for an on-premises controller. I followed the instructions on this for my version of AppDynamics - API Clients (appdynamics.com)

I created an API Client, generated the client ID, secret and I am able to generate the token by accessing the 'controller/api/oauth/access_token' endpoint.

But when I use the Authentication token and/or the username/password for accessing any other endpoint, I am getting a 500 Internal Server Error response.

Any suggestions on how to resolve this?

6 REPLIES 6

Sunil.Agarwal
AppDynamics Team

Hi Pradeep,  
Could you please do the following and let me know how it goes?

1. Go to the API Clients in Controller  -> Go to the Settings => Administrator => API Client
2. Create an API client.
3. Enter the client Name, Description and Generate the Secret. Once the secret is generated, copy the secret and save it.
4. Assign the role.
4. Save it.

If you want to generate Token via CURL Command 

5. run the below curl command to generate the token.

curl -X POST -H "Content-Type: application/vnd.appd.cntrl+protobuf;v=1" "https://test-controller.saas.appdynamics.com/controller/api/oauth/access_token" -d 'grant_type=client_credentials&client_id=<client-id>@account_name&client_secret=<secret>'

Replace <client-id> & <secret> accordingly.

client-id -> Client Name from Step 3
client_secret -> Secret from step 3

for example:
curl -X POST -H "Content-Type: application/vnd.appd.cntrl+protobuf;v=1" "https://test-controller.saas.appdynamics.com/controller/api/oauth/access_token" -d 'grant_type=client_credentials&client_id=sunil_api_client@ces-controller&client_secret=738e62b5-2455-45af-a644-934234234234'

Hi Sunil,

Thanks for your response. I am able to complete the steps from your solution and get the access token. But when I try to use the access token to access other APIs.

Example: 

curl --user <username>@customer1:<password> -H "Authorization:Bearer <ACCESS TOKEN> "https://<controller page>/controller/rest/applications"

 I am getting the following error:

<html><body><h1>500 Internal Server Error</h1><br/>Exception Id:f08d81b3-42c6-4a1e-a9ad-882dd210bad9<br/></body></html>

The same response when I try without the Access token as well. I am not sure why this happens.  

Pradeep.Prakasam
New Poster

Hi @Sunil.Agarwal,

Any idea how to resolve this?

I am still getting the same error. I even tried accessing it internally from the linux server running the controller and getting the same error. 

Hi Pradeep,  

Thank you for providing the Curl command. I noticed that you've combined two different authorization methods in the same command, "Password-Based" and "Bearer Token." To proceed, please choose either "UsernamePassword" or "Bearer Token" for this command.

Here is the revised command;  please try it and inform me of the results.

curl --user <username>@account-name:<password> "https://<controller page>/controller/rest/applications"
curl -H "Authorization:Bearer <ACCESS TOKEN> "https://<controller page>/controller/rest/applications"

 

 

Pradeep.Prakasam
New Poster

The issue was related to license not updated in the account. It is working now after refreshing the license and account details in the admin page.

That's excellent news. You can always utilize the "-v" verbose option in the Curl command to access additional details about errors and other related information, which can be invaluable for troubleshooting issues. As we discussed during the Webex call, the root cause of your API issues was the expired license. It's reassuring to hear that this matter has now been resolved.