Issue with Rest API calls for AppDynamics

554 views Asked by At

I'm trying to get the list of existing Applications using python script. Here is my script which fails. I'm new to python scripting. Basically I want to login to the application first and list the existing applications using the python script.

import requests
import json
url = "https://account.saas.appdynamics.com"
ploads = { 'Account': 'account',
           'Username': 'sara',
           'Password': 'passwd' }
response = requests.request("GET", url, params=ploads) #this will login to the application.
surl = "https://account.saas.appdynamics.com/controller/restui/v1/app/list/ids" #api call to list the application IDs
sresponse = requests.request("GET", surl)
r = json.loads(sresponse.text)
print(r)
1

There are 1 answers

0
Ingmar Boddington On BEST ANSWER

You can directly call for registered applications info from the API if you have the correct credentials. Also note that username is in fact in the format "<userName>@<accountName>".

I have tested the below script as working against a test controller:

import requests
credentials = {
    "Account": "<accountName>",
    "Username": "<userName>@<accountName>",
    "Password": "<password>"
}
applicationsUrl = "https://" + credentials["Account"] + ".saas.appdynamics.com/controller/rest/applications"
response = requests.get(applicationsUrl, auth=(credentials["Username"], credentials["Password"]))
print(response.text)

For this call to work your user needs to have the "Account Owner" permission.