Dear Friend,
I have successfully configured AppDynamics Java Agent and Controller. I can see result on browser but I am facing issue while fetching data programmatically. I am using .NET application (below code) for retrieving data but it’s throwing “The remote server returned an error: (401) Unauthorized.”. I am providing same credential which I am using in controller to see result in browser. I am looking support on priority to resolve this issue.
public string GetMemoryUsage(EventLog serviceeventlog)
{
var xml_data = string.Empty;
using (var w = new System.Net.WebClient())
{
//NetworkCredential myCreds = new NetworkCredential("admin", "admin");
NetworkCredential myCreds = new NetworkCredential(USERNAME, PASSWORD);
w.Credentials = myCreds;
try
{
//URL=192.168.1.40:8090;
// APPLICATIONNAME = “MyApplication_UAT”;
xml_data = w.DownloadString(URL + "/controller/rest/applications/" + APPLICATIONNAME + "/metric-data?metric-path=Application Infrastructure Performance|Default Web Site/" + APPLICATIONNAME + "|Hardware Resources|Memory|Used (MB)&time-range-type=BEFORE_NOW&duration-in-mins=15");
}
catch (Exception e)
{
serviceeventlog.WriteEntry("GetCpuUtilization : " + e.Message + " " + e.InnerException);
}
}
return xml_data;
}
Thanks in advance.
Regards,
Rajeev
Hi Rajeev,
If your controller is not multi-tenant then please pass username as admin@customer1 for user parameter and see if that helps. Here customer1 is default account name.
Regards,
Arun