cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2156
Views
0
Helpful
1
Replies

Getting 401 when I try to connect to Prime REST API

Robert Crowe
Level 1
Level 1

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?

1 Accepted Solution

Accepted Solutions

Robert Crowe
Level 1
Level 1

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.

View solution in original post

1 Reply 1

Robert Crowe
Level 1
Level 1

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.