facebookfacebook-graph-apifacebook-batch-request

Why does Facebook batch API request sometime return nulls?


I use Facebook's batch request quite a bit in my app. For the most part, it works really well, but one thing that confuses me is why does their API sometimes return nulls? If I get this "nulls" response, I can just try again moments later and it will work.

Here's an example:

URL:

https://graph.facebook.com/?access_token={access_token}

Request Body (prior to encoding):

batch=[{"method":"GET","relative_url":"{page_id}?return_ssl_resources=1"},{"method":"GET","relative_url":"{page_id}?return_ssl_resources=1"},{"method":"GET","relative_url":"{page_id}?return_ssl_resources=1"},{"method":"GET","relative_url":"{page_id}?return_ssl_resources=1"}]

Here's what Facebook sometimes returns:

[null,null,null,null]

If I make the same request a second later, I get the proper response:

[{"code":200,"headers":[...headers here...],"body":{...body here...},{"code":200,"headers":[...headers here...],"body":{...body here...},{"code":200,"headers":[...headers here...],"body":{},{"code":200,"headers":[...headers here...],"body":{...body here...}}]

The behavior is not always consistent. Most of the time I can try again and get a proper response. Occasionally I need to try 2 to 3 times. This problem happens dozens of times a day and it's been going on as long as I can remember. I checked my App diagnostics on Facebook and my App doesn't have any restrictions, there's no API throttling, and Facebook doesn't even list these under their "API Errors" report. Any idea why this happens?


Solution

  • It seems that this problem has corrected itself. I haven't seen this error show up for a few days now.

    Bug report here: http://developers.facebook.com/bugs/295201867209494?browse=search_4f42b29071ebc7f92807017