I wanna execute multiple requests with RequestBatch class in facebook sdk.
But I'm encountering a weird issues.That's requestBatch always return "error data" for 2nd response. The error response is:
{Response: responseCode: 200, graphObject: null, error: {HttpStatus: 400, errorCode: 601, errorType: OAuthException, errorMessage: (#601) Parser error: unexpected end of query.}, isFromCache:false}
And there is my source. In this code, I executed 2 requests. I sure that 2 requests are right, because if I execute a single request, RequestBatch will return right data. The problem will happen if I do 2 requests, and only 2nd request get the error response.
String mutualFriendPatternQuery="SELECT name,mutual_friend_count FROM user WHERE uid IN(1797105393,100000027665293)";
Bundle args1=new Bundle();
args1.putString("q", mutualFriendPatternQuery);
Request request1 = new Request(session, "fql", args1, HttpMethod.GET);
requests.add(request1);
String commonLikesQuery="SELECT page_id FROM page_fan WHERE uid = 100004429063597 AND page_id IN (SELECT page_id FROM page_fan WHERE uid = me())";
Bundle args2=new Bundle();
args2.putString("q", commonLikesQuery);
Request request2 = new Request(session, "fql", args2, HttpMethod.GET);
requests.add(request2);
RequestBatch requestBatch=new RequestBatch(requests);
requestBatch.setTimeout(60000);
List<Response> responses = requestBatch.executeAndWait();
Behind this code, responses.get(1) will return the error response. Please help me find the fault.
Update
I tested 2 behind requests with Graph API Explorer. they are ok but still get error with android. There is "batch" param:
[{"method":"POST","relative_url":"method/fql.query?query=SELECT name, mutual_friend_count FROM user WHERE uid IN(1511547166,100004190323671)"}
,{"method":"POST","relative_url":"method/fql.query?query=SELECT page_id FROM page_fan WHERE uid= 652869235 AND page_id IN (SELECT page_id FROM page_fan WHERE uid = me())"}
Fixed It's my stupid fault. Change args1 to args2 to fix.
I think this is your problem:
Bundle args2=new Bundle();
args1.putString("q", commonLikesQuery); // <----- this should be args2.putString(...)