Take the 2-minute tour ×

I've seen a couple posts about this issue, but so far nothing has seemed to help me. Basically, I'm writing an iOS app and attempting to post a photo to a Facebook album using the Graph API. The image data is first downloaded from a server, and then POSTed to Facebook. I'm using the ASIFormDataRequest class and the url https://graph.facebook.com/MY_ALBUM_ID/photos, but I'm consistently getting the following error:

error =     {
    message = "(#1) An unknown error occurred";
    type = OAuthException;

My request looks like this:

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:url]];
self.photoRequest = request;
[request setDelegate:self];
[request setPostValue:token forKey:@"access_token"];
[request setPostValue:message forKey:@"message"];
[request setTimeOutSeconds:240];
[request setRequestMethod:@"POST"];

UIImage *image = [UIImage imageWithData:data];

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    NSData *imageData = UIImageJPEGRepresentation(image, 0.8);
    [request setData:imageData forKey:@"source"];

    dispatch_async(dispatch_get_main_queue(), ^{
        [request startAsynchronous];

The strange part is that I'm using the exact same method to upload photos to my server for a different part of the application, and everything works fine. I've even uploaded the photo I'm trying to send to Facebook to my server to see if the data was POSTing correctly. Everything came out okay.

I've read that Facebook can sometimes spit back the error I'm seeing if it has a problem with the image format, but the error in and of itself is pretty nebulous. I know my access_token is valid. All other requests I'm making to Facebook are working just fine.

Any thoughts?

share|improve this question
thinked about a network related issue? like because of a firewall? or maybe image too big? :) from the google search results I see it looks like an HTTP 400, which is a malformed request... –  Vincent Guerci Jun 4 '11 at 0:01
@Vincent G It's definitely not a network related issue. As a test, I uploaded a random image from my project using [UIImage imageNamed:@"imageName"]; instead of UIImage *image = [UIImage imageWithData:data]; and it posted just fine. We're using ImageMagick on our server to generate the image I'm trying to send. It seems like the problem lies in the image data being generated by ImageMagick. –  harrisonlee Jun 4 '11 at 1:17
Okay, so the issue is beyond ImageMagick. Playing around in photoshop and trying to add images to facebook: some work, some don't. I can't find what it is about particular images that don't want to upload. The images that don't upload from my app also don't upload when I try to post them manually within facebook itself. Weird. –  harrisonlee Jun 4 '11 at 1:56
have you set the mime-type of the request?... the format detection on facebook side might fail without? Also seen reports that It could be security based rejection from facebook (like too many requests... IP blacklisted...) you could try from another IP/network to check this. –  Vincent Guerci Jun 4 '11 at 8:27

3 Answers 3

up vote 3 down vote accepted

Okay so, I figured it out!

As it happens, Facebook has ratio restrictions to uploaded images. I'm still not sure what they are, but in my case, a 198x715 image didn't fit their ratio requirements. We contacted one of the guys we know on the Facebook dev team, and he said that they weren't going to change the restrictions, but they would add better messaging to the API error.

Hope that helps anybody out there with similar problems.

share|improve this answer
I suddenly have the same problem, since the middle of August. Using the latest FB iOS SDK, all image upload calls keep failing with error response {"error":{"message":"(#1) An unknown error occurred","type":"OAuthException"}}. I've tried different image sizes, but all fail equally. Any more ideas? This is holding back a major iPad/iPhone app release for my client now. Also tried it from a different IP, in case my home IP is blacklisted for some reason, but the same results. –  Edwin Sep 23 '11 at 9:24
Ok, I figured out my problem as well. In my case the upload failed because the "message" parameter I was passing along with the upload contained an http:// link (goo.gl link to an app in Apple's App Store). Either that, or the message value was too long. –  Edwin Sep 26 '11 at 12:08

There is an image restriction that is not documented, or at least I couldn't found anything, the aspect ratio limit is 1:3 when the height is bigger than the width on the image. I did many tests to confirm this and I can assure you this is the limit as of today.

share|improve this answer

Like stated in this answer the problem can be caused when your application is in Sandbox mode.

share|improve this answer

Your Answer


