Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gmail api Thread List Snippet

I have been attempting to work with the GMail API and client libraries. I'm able to use the javascript node SDK to get a list of threads, but the snippet comes back as "".

client.gmail.users.threads.list({userId: "me"}).withAuthClient(auth_with_access_token).execute(function (err, response) {
            res.json({complete: response.threads})
        });

I then downloaded the python SDK and got a list of threads as well using the gmail api sample and noticed those have empty snippets as well.

for thread in threads['threads']:
    print 'Thread: %s' % (thread)

Thread ID: {u'snippet': u'', u'id': u'146fccb21d960498', u'historyId': u'7177452'}

When I request the thread via the get thread method I do get a snippet, though, it's only missing on the thread list.

Is there additional details I need to include in the request to get the snippet?

Thanks!

like image 927
tranqy Avatar asked Oct 21 '22 05:10

tranqy


1 Answers

I can grab message snippets fine by using this code, following authentication:

message = service.users().messages().get(userId=user_id, id=msg_id, format='raw').execute()
print 'Message snippet: %s' % message['snippet']

This is obviously pulling a snippet for a particular message, but the principle remains.

Try this out and it should work, if not comment on this answer and I'll try to help.

like image 123
LeonH Avatar answered Oct 24 '22 09:10

LeonH