AppD Archive

Unable to read response using REST service

CommunityUser
Splunk Employee
Splunk Employee

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

0 Karma

Arun_Dasetty
Super Champion

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

0 Karma
Get Updates on the Splunk Community!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...