17

I am running the Facebook SDK 3.1 on Xcode 4.5GM with iOS6 simulator. I connect to FB in the iOS settings and successfully FB connect in my app using the new iOS6 FBConnect UI. I have an access token, can see my friends, send app requests, post to my wall, etc. However, every time I initiate any sort of FBURLConnection is made, I see this printed to my console:

Error: HTTP status code: 400

I went into the FB code and printed the reponse when this error is printed and I get:

{
    body =     {
        error =         {
            code = 100;
            message = "(#100) The parameter 'attribution' is required for the 'mobile_app_install' activity";
            type = OAuthException;
        };
    };
    code = 400;
}

Does anyone know how to resolve this? All functionality seems to work, but I keep seeing this spam my console.

stipe108
  • 1,640
  • 1
  • 16
  • 20
  • I can't even connect properly. I've even followed the guide at: https://developers.facebook.com/docs/tutorial/iossdk/upgrading-from-3.0-to-3.1/ – Joakim Engstrom Sep 26 '12 at 16:23

6 Answers6

18

Right after the session is created do this:

[FBSession setActiveSession:session];
3

As best as I can tell, this is a bug introduced in the 3.1 SDK. Looking at the network traffic with Charles, they’re trying to POST to graph.facebook.com/[user id]/activities but it’s failing.

cbowns
  • 6,295
  • 5
  • 47
  • 64
  • I'm thinking this is a new thing dealing with their tracking of installs for their new Mobile Ads. That requires an "attribution" ID to identify the device which matches with the missing "attribution" response I see. – stipe108 Sep 26 '12 at 22:56
  • There might be error or something else don't know. But I concluded that for the particular user Facebook allows Post to be updated only for 15-20 times, then it'll give code: 400 error – Paresh Thakor Sep 27 '12 at 06:44
  • I'm having this with 3.1 SDK. With Charles I spotted this call to be responsible: http://0-op-w.channel.facebook.com – Valerio Sep 27 '12 at 09:56
  • I’ve filed this in their bug tracker: https://developers.facebook.com/bugs/115149961972168 – cbowns Oct 02 '12 at 01:01
2

After much troubleshooting and looking at all the suggestions on Stackoverflow, I got this error 400 (error.code = 5) thing resolved. The solution in my case was to make sure the params (aka postParams) included in my startWithGraphPath call had exactly the params supported by the type of content being posted.

More specifically, I was posting a link to me/feed with the @"ref" key (typically used for tracking with FB Insights).

After removing the @"ref" key, startWithGraphPath succeeded.

NSMutableDictionary *postParams = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   @"Test NAME field (from ios app)", @"name",
                                   @"Test caption", @"caption",
                                   @"Test description", @"description",
                                   @"http://example.com/test1.html", @"link",
                                   @"http://example.com/water.jpg", @"picture",
                                   // @"foo", @"ref",  // WRONG!
                                   nil];

[FBRequestConnection startWithGraphPath:@"me/feed"
                             parameters:postParams
                             HTTPMethod:@"POST"
                      completionHandler:^(FBRequestConnection *connection,
                                          id result,
                                          NSError *error)

My activeSession (and all other possible culprits) checked-out OK.

Donn Lee
  • 2,962
  • 1
  • 24
  • 16
0

This is the same as my answer from here: Facebook SDK 3.1 - Error: HTTP status code: 400

But it could help people still getting the 400 error.

The original issue was resolved by Facebook just after the 3.1 SDK was released.

But some are still having issues, if you have this issue you should check the login flow, and look at facebooks examples, if you are still having issues this could be a hint to a solution.

I got the 400 error when I do not have authorization to get to my information. The strange thing is that I get an accessToken and even a valid login (this is because I structured my code, with the help according to Scrumptious example and I did a valid login when the Session state is open).

The FBSessionState is only opened for like a second and then it changes to closed with an 400 Error.

With iOS6 native login you get the permission alert when you ask for it, and then the phone remember that choice for 24 hours. But if the user logs in to the facebook home-page and then deletes permission for the application the phone will remember that setting for 24 hours, regardless if you re-install the app or not.

This I found out after some hours of debugging, since I allowed the application from the Settings in iOS, but I could not post, and since I deleted the permission from the facebook privacy, and the alert would not show again there was nothing I could do but to manually give me permissions via a debug tool or wait 24 hours so I could accept the facebook-permission alert again.

Community
  • 1
  • 1
Joakim Engstrom
  • 6,243
  • 12
  • 48
  • 67
0

I discovered that Status Code 400 is also thrown with FBErrorHTTPError when something go wrong with Optional Properties in Define Action Type fieldset, within the Facebook=>Open Graph definition panel.

In my case I was posting an action object without a property marked as isRequired. Be also aware for isArray option and in general, for right matching with what you're sending.

brainondev
  • 1,117
  • 1
  • 11
  • 20
-2

This error reflected a bug on the server, which was fixed shortly after the 3.1 release was published. At this point there should be no more failures coming from this request. Hope this helps!

Jason Clark
  • 1,343
  • 8
  • 8
  • 7
    I'm still seeing this in 3.1. It occurs the first time the app requests permissions (if I've deleted the FB app from the list of authorized apps in my settings). Subsequent requests work, however. This seems to only happen on the device, not in the simulator. – Senior Oct 16 '12 at 20:24