Facebook iOS SDK 3.1: "Error: HTTP status code: 400"

10,842

Solution 1

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!

Solution 2

Right after the session is created do this:

[FBSession setActiveSession:session];

Solution 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.

Solution 4

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.

Share:
10,842

Related videos on Youtube

stipe108
Author by

stipe108

Updated on June 03, 2022

Comments

  • stipe108
    stipe108 almost 2 years

    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
    stipe108 over 11 years
    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.
  • Paresh Thakor
    Paresh Thakor over 11 years
    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
  • Valerio
    Valerio over 11 years
    I'm having this with 3.1 SDK. With Charles I spotted this call to be responsible: 0-op-w.channel.facebook.com
  • cbowns
    cbowns over 11 years
    I’ve filed this in their bug tracker: developers.facebook.com/bugs/115149961972168
  • Senior
    Senior over 11 years
    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.