I'm able to use GMail's Users.threads.list API call to retrieve a list of the threads. I'd like to also grab the labels belonging to each message in the thread.
On the official documentation / live example for this method, there is an area called fields where the user can specify the optional fields they wish to pull in. They even provide a little UI tool call 'fields editor' to help you select and properly format the fields for inclusion in the REST query:
Which results in the following, valid, generated fields parameter values:
nextPageToken,resultSizeEstimate,threads(historyId,id,messages/labelIds)
The final request looks like this:
GET https://www.googleapis.com/gmail/v1/users/me/threads?includeSpamTrash=true&fields=nextPageToken%2CresultSizeEstimate%2Cthreads&key={YOUR_API_KEY} After authenticating with OAuth2, I get back a list of threads[], but none of them include the expected messages[] array nested within them! I know the field mask is valid because GMail API errors out when you request a field the method doesn't support with a standard HTTP 400 and a pretty printed error message. But in this case, all I get back is an object that contains an array labeled "threads", where each thread object only has the following fields:
- id
- snippet
- historyId
But no messages array. Stranger yet, even when I remove the fields custom filter parameter, I still get back these same results. Am I missing something obvious here?
