facebookfacebook-graph-apifacebook-batch-requestfacebook-field-expansion

Facebook: field expansion in batch requests?


Is it possible to make a batch request with one (or more) of the batched requests using field expansion?

For instance, say I'd like information about me, my listen data. These are the three batch requests I wrap up:

{'method': 'GET', 'relative_url': 'me'}
{'method': 'GET', 'relative_url': 'me/music.listens'}
{'method': 'GET', 'relative_url': 'me/friends?fields=name,first_name,last_name,music.listens.limit(1)'}

But when I make the batch request, the first two responses come back with the data I expect and the third response comes back with data in this format (not the data I requested):

{'access_token': '<access token here>'}

I read all about batch requests here:

https://developers.facebook.com/docs/graph-api/making-multiple-requests/

and about field expansions here:

https://developers.facebook.com/docs/graph-api/using-graph-api/

Am I missing something?


Solution

  • You could even combine this into one query:

    /me?fields=name,first_name,last_name,music.listens,friends.fields(name,first_name,last_name,music.listens.limit(1))
    

    I noticed that you have a surplus "u" in your request definition

    {'method': 'GET', 'relative_url': u'me'}

    maybe you should fix this. Anyway, as I said, you dont need the Batch API to combine the requests.