title: Get JSON with HTTP Authentication with AFNetworking
body: <p>I am trying to get a JSON from my hudson url address and authenticate my (Mac OS X) application using the HTTP Authenticate.</p>
  
  <p>Following the example I'm using:</p>
  
  <pre><code>// AppDelegate.m
  - (void) doSomething {
      [[CommAPIClient sharedClient] getPath:@"/computer/api/json" parameters:nil
  success:^(AFHTTPRequestOperation *operation, id responseObject) {
          NSLog(@"Name: %@", [responseObject valueForKeyPath:@"totalExecutors"]);
  
      } failure:nil];
  }
  
  // CommAPIClient.m
  + (CommAPIClient *) sharedClient {
      static CommAPIClient *_sharedClient = nil;
      static dispatch_once_t onceToken;
  
      dispatch_once(&amp;onceToken, ^{
          AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate];
          _sharedClient = [[self alloc] initWithBaseURL:[NSURL URLWithString:    [appDelegate.hudsonTextField stringValue]]];
      });
      return _sharedClient;
  }
  
  - (id) initWithBaseURL:(NSURL *)url {
      self = [super initWithBaseURL:url];
      if (self){
          [self registerHTTPOperationClass:[AFJSONRequestOperation class]];
  
          AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate];
          userName = [appDelegate.userTextField stringValue];
          password = [appDelegate.passwdTextField stringValue];
  
          [self setAuthorizationHeaderWithUsername:userName password:password];
          [self setDefaultHeader:@"Accept" value:@"application/json"];
      }
      return self;
  }
  </code></pre>
  
  <p>I want to get the computer's list to show in my dropdown, but this two lines does not work together:
      [self setAuthorizationHeaderWithUsername:userName password:password];
      [self setDefaultHeader:@"Accept" value:@"application/json"];</p>
  
  <p>If I just use the first line, my authetication works, but I receive that error because I try to get a key:</p>
  
  <pre><code>2012-02-03 02:43:57.542 HudsonSlave[7523:707] An uncaught exception was raised
  2012-02-03 02:43:57.542 HudsonSlave[7523:707] [&lt;NSConcreteData 0x100850000&gt; valueForUndefinedKey:]: this class is not key value coding-compliant for the key totalExecutors.
  
  2012-02-03 02:43:57.623 HudsonSlave[7523:707] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[&lt;NSConcreteData 0x100850000&gt; valueForUndefinedKey:]: this class is not key value coding-compliant for the key totalExecutors.'
  </code></pre>
  
  <p>If use the second line, my authentication will return an error 403.</p>
  
  <p>Anyone could help with problem ?</p>
  
  <p>Thanks and apologize for any errors in english.</p>
  
  <p>Thiago</p>