title: Getting/updating YouTube favorites using Objective-C
body: <p>I am trying to work with youtube apis. I have 2 methos to get favorite list and add a specified video to that list. Both methods not work. I received the error as below: <code>HTTP/1.1 401 Unknown authorization header</code> error.
  Here is my codes:</p>
  
  <pre><code>#define CONNECTION_YOUTUBE                  @"https://gdata.youtube.com/feeds/api/"
  #define CONNECTION_ADD_FAVORITE_VIDEO @"users/default/favorites"
  #define CONNECTION_GET_FAVORITE_LIST @"https://gdata.youtube.com/feeds/api/users/default/favorites"
  
  - (void) getFavoriteList{
      NSURL *url = [NSURL URLWithString:CONNECTION_GET_FAVORITE_LIST];
      ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:url];
      AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
      [request addRequestHeader:@"Authorization" value:[@" Bearer "  stringByAppendingString:[appDelegate userInfo].accessTokenYoutube ]];
      [request addRequestHeader:@"X-GData-Key" value:[NSString stringWithFormat:@"key=%@",YOUTUBE_DEVELOPER_KEY]];
  
      [request startAsynchronous];
      [request setCompletionBlock:^{
          NSString* respondMessage = [request responseStatusMessage];
          NSLog(@"Respond compelet with message: %@",respondMessage);
      }];
      [request setFailedBlock:^{
          NSString* respondMessage = [request responseStatusMessage];
          NSLog(@"Respond failed with message: %@",respondMessage);
      }];
      [request release];
  }
  - (void) addToFavoriteTheVideoWithID:(NSString *)strVideoID{
  
      //prepare url
      NSString *rawUrl = [NSString stringWithFormat:@"%@%@", CONNECTION_YOUTUBE, CONNECTION_ADD_FAVORITE_VIDEO    ];
      NSURL *url = [[NSURL URLWithString:rawUrl] autorelease];
  
      ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease];
  
      //prepare form body
      NSString *rawXML = [NSString stringWithFormat:@"&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt; &lt;entry xmlns=\"http://www.w3.org/2005/Atom\"&gt;&lt;yt:videoid&gt;xxxx%@&lt;/yt:videoid&gt;&lt;/entry&gt;",strVideoID];
      NSMutableData *soapData = [[[NSMutableData alloc]initWithData:[rawXML dataUsingEncoding:NSUTF8StringEncoding ]]autorelease] ;
      [request setPostBody:soapData];
  
      //prepare request header
      AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
      [request setRequestMethod:@"POST"];
      [request addRequestHeader:@"SOAPAction" value:@""];
      [request addRequestHeader:@"Content-Type" value:@"application/atom+xml"];
      [request addRequestHeader:@"Content-Length" value:[NSString stringWithFormat:@"%d",soapData.length]];
      [request addRequestHeader:@"Authorization" value:[@" Bearer "  stringByAppendingString:[appDelegate userInfo].accessTokenYoutube ]];
     // NSString* token = [@" Bearer "  stringByAppendingString:[appDelegate userInfo].accessTokenYoutube ];
      [request addRequestHeader:@"GData-Version" value:@"2"];
      [request addRequestHeader:@"X-GData-Key" value:[NSString stringWithFormat:@"key=%@",YOUTUBE_DEVELOPER_KEY]];
  
      [request startAsynchronous];
      [request setDelegate:self];
      [request setDidFinishSelector:@selector(didAddVideoToFavoriteFinish: )];
      [request setDidFailSelector:@selector(didAddVideoToFavoriteFail:)];
  
  }
  </code></pre>
  
  <p>Please helps.
  Thanks a bunch.</p>