Youtube video upload fails after 100 % progress for some users with Backend Error code:-32099

828 Views Asked by At

I have added youtube api v3 using google api's objective-C client in my app to upload video to youtube. Testers of the app (in different country) reports that they are unable to upload video to youtube. Video uploading fails after reaching to 100 % progress with backend error. Where as I am not facing that issue in my end here in India. Testers also confirms that youtube video upload is working fine when uploaded using youtube ios app or some different app. They also tried uploading videos from multiple accounts but with same result.

The error log from device console is:

Error Domain=com.google.GTLJSONRPCErrorDomain Code=-32099 "The operation couldn’t be completed. (Backend Error)" UserInfo=0x2438c380 {error=Backend Error, GTLStructuredError=GTLErrorObject 0x27ea3990: {message:"Backend Error" code:-32099 data:[1]}, NSLocalizedFailureReason=(Backend Error)} 

and my code that I am using to upload video to youtube is:

GTMOAuth2Authentication *auth = [GTMOAuth2ViewControllerTouch authForGoogleFromKeychainForName:YoutubeOAuthKeyChain clientID:GoogleAPIClientID clientSecret:GoogleAPIClientSecret];
if (!auth) {
    [self signInToGoogle];
}else{
    if ([auth canAuthorize] && auth.userEmail) {
        //Force the api to refresh access token if needed
        [auth authorizeRequest:Nil completionHandler:^(NSError *error) {
           dispatch_async(dispatch_get_main_queue(), ^{
               if (!error) {
                   NSLog(@"Youtube: App authorized. Uploading video now");

                   self.youTubeService.authorizer = auth;
                   GTLYouTubeVideoStatus *status = [GTLYouTubeVideoStatus object];

                   status.privacyStatus = @"public";

                   GTLYouTubeVideoSnippet *snippet = [GTLYouTubeVideoSnippet object];
                   snippet.title  = _captionTextView.text;

                   snippet.descriptionProperty = @"This is a test video";

                   GTLYouTubeVideo *video = [GTLYouTubeVideo object];
                   video.status = status;
                   video.snippet = snippet;
                   NSString *filename = [_moviePath lastPathComponent];
                   NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:_moviePath];
                   if (fileHandle) {
                       NSString *mimeType = [self MIMETypeForFilename:filename
                                                      defaultMIMEType:@"video/mp4"];
                       GTLUploadParameters *uploadParameters = [GTLUploadParameters uploadParametersWithFileHandle:fileHandle MIMEType:mimeType];
                       uploadParameters.uploadLocationURL = nil;
                       //uploadParameters.shouldSendUploadOnly = YES;

                       GTLQueryYouTube *query = [GTLQueryYouTube queryForVideosInsertWithObject:video  part:@"snippet,status" uploadParameters:uploadParameters];

                       GTLServiceYouTube *service = self.youTubeService;

                       GTLServiceTicket *ticket = [service executeQuery:query completionHandler:^(GTLServiceTicket *ticket, id object, NSError *error) {
                           dispatch_async(dispatch_get_main_queue(), ^{

                               if (!error) {
                                   NSLog(@"Youtube video upload completed ");

                               }else{
                                    NSLog(@"error completing request with error: %@", error);                               
                               }

                           });


                       }];
                       [ticket setUploadProgressBlock:^(GTLServiceTicket *ticket, unsigned long long totalBytesWritten, unsigned long long totalBytesExpectedToWrite) {

                               float progress = ((float)totalBytesWritten / (float)totalBytesExpectedToWrite) * 100.0f;
                               NSLog(@"%f %% uploaded");


                       }];
                   }

               }else{
                   //Error authorizing the request

                   NSLog(@"error authorizing request with error: %@", error);
               }

           });
        }]; 
    }else{
        //Refresh access token
        [self signInToGoogle];
    }

}

This issue started just 2 weeks ago. I have no idea if this is a server side issue of some issue with my app. Has anyone also have the same issue?

0

There are 0 best solutions below