GMail API Users.threads.list Missing Messages Field

I can use the GMail Users.threads.list API call to retrieve a list of threads. I would also like to capture tags that belong to each message in the thread.

In the official documentation / live example for this method, there is an area called fieldswhere the user can specify optional fields they even want to receive. They even provide a small “user interface” tool editor that will help you select and correctly format the fields to include in your REST request:

enter image description here

This leads to the following, valid, generated parameter values fields:

nextPageToken, resultSizeEstimate, (historyId, /LabelIds )

:

GET https://www.googleapis.com/gmail/v1/users/me/threads?includeSpamTrash=true&fields=nextPageToken%2CresultSizeEstimate%2Cthreads&key={YOUR_API_KEY}

OAuth2 threads[], messages[], ! , , GMail API , HTTP 400 . , , , "threads", :

  • ID
  • historyId

. , fields, . - ?

+4
1

, , . API Explorer - .

1.

GET https://www.googleapis.com/gmail/v1/users/me/threads?access_token={access_token}

{
 "threads": [
  {
   "id": "1570f8c16a1084de",
   "snippet": "Foo bar...",
   "historyId": "1234"
  }, ...
 ],
 "resultSizeEstimate": 100
}

2.

GET https://www.googleapis.com/gmail/v1/users/me/threads/1570f8c16a1084de?access_token={access_token}

{
 "id": "1570f8c16a1084de",
 "historyId": "1234",
 "messages": [
  {
   "id": "1570f8c16a1084de",
   "threadId": "1570f8c16a1084de",
   "labelIds": [
    "INBOX",
    "IMPORTANT",
    "CATEGORY_FORUMS"
    ], ...
   }
  }

, , , 2 .

+1

Source: https://habr.com/ru/post/1654282/


All Articles