8
votes

I have an app that posts native (MOV files) video to Facebook using the Facebook SDK for iOS. It worked without problems till a few weeks ago where it started failing with the following error:

    error =         {
        code = 352;
        message = "(#352) Sorry, the video file you selected is in a format that we don't support.";
        type = OAuthException;
    };

The full error string is:

Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x1ea42880 {com.facebook.sdk:HTTPStatusCode=400, com.facebook.sdk:ParsedJSONResponseKey={ body = { error = { code = 352; message = "(#352) Sorry, the video file you selected is in a format that we don't support."; type = OAuthException; }; }; code = 400; headers = ( { name = "Access-Control-Allow-Origin"; value = "*"; }, { name = "Cache-Control"; value = "no-store"; }, { name = Connection; value = close; }, { name = "Content-Type"; value = "text/javascript; charset=UTF-8"; }, { name = Expires; value = "Sat, 01 Jan 2000 00:00:00 GMT"; }, { name = Pragma; value = "no-cache"; }, { name = "WWW-Authenticate"; value = "OAuth \"Facebook Platform\" \"invalid_request\" \"(#352) Sorry, the video file you selected is in a format that we don't support.\""; }, { name = "x-fb-loadmon"; value = "0,30,70"; } ); }, com.facebook.sdk:ErrorSessionKey=, expirationDate: 4001-01-01 00:00:00 +0000, refreshDate: 2013-10-15 17:19:33 +0000, attemptedRefreshDate: 2013-10-24 14:56:54 +0000, permissions:( "share_item", email, "user_photos", "user_videos", "publish_checkins", "manage_pages", "read_friendlists" )>}

The code I use to post is similar to this:

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   videoData,@"video.mov",
                                   @"video/quicktime", @"contentType",
                                   title, @"title",
                                   status, @"description",
                                   nil];

FBRequest* request = [FBRequest requestWithGraphPath:[NSString stringWithFormat:@"%@/videos",@"me"]
                                              parameters:params
                                              HTTPMethod:@"POST"];

    [request setSession:session];

    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0ul);
    dispatch_async(queue, ^{
        dispatch_async(dispatch_get_main_queue(), ^(void) {

            [request startWithCompletionHandler:^(FBRequestConnection* conn, id data, NSError* error){
                SSLog(@"DONE!");

                [self processResponseWithData:data requestIdentifier:requestIdentifier andError:error];
            }];
        });
    });

I have updated to the latest SDK version (3.9) but the error is still there. Any body is experiencing this error?

I'm testing with iOS6 and iOS7, so the problem is not related with the OS version. The same video uploads okey using the iOS-Facebook built in function.

Thanks very much!

4
I received the same error. I was attempting to upload a MP4 video, not a MOV. The solution was to change the videoData parameter name to @"video.mp4", and change the contentType value to @"video/mp4". - Jonathan Nesbitt
Having the same issue with a .mov file. Everything seems to be according to fb documentation. - dwbrito
I also ran into this problem after a week. The same code was working. - Bo.

4 Answers

8
votes

Just before FBRequest Add a line to open FBRequestConnection Worked for me.

[FBRequestConnection startWithGraphPath:@"me/videos" 
    completionHandler:^(FBRequestConnection *connection, 
    id result, NSError *error) 
{
    FBRequest *uploadRequest = 
        [FBRequest requestWithGraphPath:@"me/videos" 
        parameters:params HTTPMethod:@"POST"];
}];
2
votes

Answers above work. But make sure you created the Facebook session, with openActiveSessionWithPublishPermissions not openActiveSessionWithReadPermissions.

I spent a day on this, because if you use the wrong one, you get the (in)famous "(#352) Sorry, the video file you selected is in a format that we don't support."

In any case the only permission you really need is publish_actions

1
votes

I don't use key contentType int params. It works well with Facebook SDK 3.10 (latest)

NSData *videoData = [NSData dataWithContentsOfFile:filePath];    
NSString* videoName = [filePath lastPathComponent];
NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
[params setObject:caption forKey:@"description"];
[params setObject:videoData forKey:videoName];

FBRequestConnection *requestConnection = [FBRequestConnection startWithGraphPath:@"me/videos"
                             parameters:params
                             HTTPMethod:@"POST"
                      completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{

}];
0
votes

I had the same error message and the cause was the filename didn't match the encoding.

I was converting gif to mp4 and uploading, but my filename was still *.gif