11-03-2015 11:41 AM
I'm trying to write a client for the Prime REST API in ASP.NET C#, but when I try to connect I get a 401 Unauthorized exception. I've created a user and added him to the North Bound API group. Using this code, I try to connect:
IgnoreBadCertificates(); // accepts untrusted certificates
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(@"https://172.26.170.20/webacs/api/v1/data/AccessPoints");
string svcCredentials = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes("apiuser" + ":" + "apiuserpassword"));
req.Headers.Add("Authorization", "Basic " + svcCredentials);
WebResponse svcResponse = (HttpWebResponse)req.GetResponse(); // throws a 401
This seems to be about as simple as it could be, but it fails. Any ideas?
Solved! Go to Solution.
11-03-2015 11:55 AM
Nevermind, I found the problem. The user needs to be in the Admin group, not North Bound API. The request /webacs/api/v1/data/AccessPoints was also a problem.
11-03-2015 11:55 AM
Nevermind, I found the problem. The user needs to be in the Admin group, not North Bound API. The request /webacs/api/v1/data/AccessPoints was also a problem.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide