Showing results for 
Show  only  | Search instead for 
Did you mean: 
Not a customer? Start a free trial

Click the Start a free trial link to start a 15-day SaaS trial of our product and join our community as a trial user. If you are an existing customer do not start a free trial.

AppDynamics customers and established members should click the sign in button to authenticate.

Controller (SaaS, On Premises)

Accessing Controller API from Web App


Accessing Controller API from Web App

I'm running into issues making REST calls to our controller API when calling through a web app.  When I make the same call via Postman or Fiddler it authenticates and responds as expected.  When calling programatically via a web client, I get back a 401 Unauthorized response.


URL: https://<my Saas Controller host>:<port>/controller/api/accounts/<Account id>/users

Key: Authorization  Val: Username@AccountName:Password (Base64 encoded)


Any suggestions as to why the discrepancy?  Or what needs to change to allow calls from the web client?

By replying you agree to the Terms and Conditions of the AppDynamics Community.
Accessing Controller API from Web App

Posting some additional detail following research:


When I add the Authorization request headers, CORS causes the browser to treat this as a Preflight request and changes the request method to OPTIONS.  The thing I'm struggling with is if I remove the Authorization header, the API will not be able to authenticate me. 


The relevant angular code below is what I'm using, cut out unneccesary details:



const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': 'Basic <Base64 encoded username@client:password>'

export class UserService {
private usersUrl = 'https://<controller><client id>/users';
getUsers(): Observable<User[]> {
return this.http.get<User[]>(this.usersUrl, httpOptions)
tap(_ => this.log('fetched users')),
catchError(this.handleError('getUsers', []))