title: Gdata youtube upload failedWithStatus:400
body: <p>i have a small app in which i use gdata to upload a video to youtube. Everytime I try, I get the following error: "serviceBase: objectFetcher: failedWithStatus:400 data:GData<code>InvalidRequestUriException</code>Missing or invalid username."</p>
  
  <p>I tried using my youtube accout, or my gmail accout and none worked. Any help would be appreciated.</p>
  
  <p>here is the code:</p>
  
  <pre><code>NSString *devKey = DEVELOPER_KEY;
  
  GDataServiceGoogleYouTube *service = [self youTubeService];
  [service setYouTubeDeveloperKey:devKey];
  
  NSString *username = @".........@gmail.com";
  NSString *clientID = CLIENT_ID;
  
  NSURL *url = [GDataServiceGoogleYouTube youTubeUploadURLForUserID:username
                                                           clientID:clientID];
  
  // load the file data
  
  NSString  *videoPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/output.mp4"];
  
  //    NSString *path = [[NSBundle mainBundle] pathForResource:@"YouTubeTest" ofType:@"m4v"]; 
  NSData *data = [NSData dataWithContentsOfFile:videoPath];
  NSString *filename = [videoPath lastPathComponent];
  
  // gather all the metadata needed for the mediaGroup
  NSString *titleStr = [titleTextField text];
  GDataMediaTitle *title = [GDataMediaTitle textConstructWithString:titleStr];
  
  NSString *categoryStr = [mCategoryField text];
  GDataMediaCategory *category = [GDataMediaCategory mediaCategoryWithString:categoryStr];
  [category setScheme:kGDataSchemeYouTubeCategory];
  
  NSString *descStr = [mDescriptionField text];
  GDataMediaDescription *desc = [GDataMediaDescription textConstructWithString:descStr];
  
  NSString *keywordsStr = [mKeywordsField text];
  GDataMediaKeywords *keywords = [GDataMediaKeywords keywordsWithString:keywordsStr];
  
  BOOL isPrivate = mIsPrivate;
  
  GDataYouTubeMediaGroup *mediaGroup = [GDataYouTubeMediaGroup mediaGroup];
  [mediaGroup setMediaTitle:title];
  [mediaGroup setMediaDescription:desc];
  [mediaGroup addMediaCategory:category];
  [mediaGroup setMediaKeywords:keywords];
  [mediaGroup setIsPrivate:isPrivate];
  
  
  NSString *mimeType = [GDataUtilities MIMETypeForFileAtPath:videoPath defaultMIMEType:@"video/mp4"];
  
  // create the upload entry with the mediaGroup and the file data
  GDataEntryYouTubeUpload *entry;
  
  NSLog(@"%@", mimeType);
  
  entry = [GDataEntryYouTubeUpload uploadEntryWithMediaGroup:mediaGroup
                                                        data:data
                                                    MIMEType:mimeType
                                                        slug:filename];
  
  SEL progressSel = @selector(ticket:hasDeliveredByteCount:ofTotalByteCount:);
  [service setServiceUploadProgressSelector:progressSel];
  
  GDataServiceTicket *ticket;
  ticket = [service fetchEntryByInsertingEntry:entry
                                    forFeedURL:url
                                      delegate:self
                             didFinishSelector:@selector(uploadTicket:finishedWithEntry:error:)];
  
  [self setUploadTicket:ticket];
  </code></pre>
  
  <p>}</p>