0

I am trying to execute multiple requests at the "executeBatchAndWait" method. I am expecting the function to return only after all requests have been executed and all response received. But, the function returns instantly. And when I do,

response.getGraphObject().getInnerJSONObject();

It throws a null pointer exception.

CODE:

Log.v(TAG, "executing album requests");
List<Response> mResponsesList = Request.executeBatchAndWait(mAlbumPhotosRequests);
Log.v(TAG, "received album responses");

OUTPUT

02-13 15:48:45.900: executing album requests

02-13 15:48:45.904: received album responses

asloob
  • 1,308
  • 20
  • 34

2 Answers2

0

Check if there is any error in your response before accessing the JSON Object.

response.getError()

It may be the reason why the GraphObject is not created

Ashwini Bhangi
  • 291
  • 1
  • 6
  • I would 1. try one request at a time 2. check the responses in the Graph Explorer tool - https://developers.facebook.com/tools/explorer, you can use your access token there or make sure the default access token has the required permissions – Ashwini Bhangi Feb 20 '13 at 10:24
  • I am using executeBatchAsync() for now and it works perfectly, but while waiting for response (for all requests) using requestAsyncTask.get(); I have to wait on the UI thread which I am trying to avoid. – asloob Feb 20 '13 at 10:50
  • You can start your own async task, request for batch in the background & then in postprocess update the UI. Till then show a loading/wait screen probably – Ashwini Bhangi Feb 20 '13 at 11:28
  • I have tried this. It exits doInBackground() immediately and in PostExecute() gives NullPointerException for the response.getGraphObject().getInnerJSONObject(); – asloob Feb 21 '13 at 04:37
  • Try using this when you before you setup your Facebook session Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_RAW_RESPONSES); Settings.addLoggingBehavior(LoggingBehavior.REQUESTS); This should dump what is exactly happening when the requests are made – Ashwini Bhangi Feb 21 '13 at 11:59
0

You're getting an empty response. This is a scenario usually related with running simultaneous FB requests on your own threads. I learnt the hard way to use either

Request.executeAsync()

or

RequestAsyncTask
Vaiden
  • 15,728
  • 7
  • 61
  • 91