4

The list() method only returns a list of message IDs without any other message metadata. There are SO posts from 2014 and 2016, but the official documentation states that the response is a list of user.messages resource ...

Is the documentation wrong or is there any other way to do this? I understand that bringing the entire message in a "list" call is not efficient for a REST API call - but maybe returning "some" metadata would make sense (e.g. output of service.users().messages().get(..., format='metadata')) as opposed to making a call to list() and then, for every message, make a get(..., format='metadata')

Thanks!

M

Neurus
  • 657
  • 4
  • 27
  • 4
    You need to list the message ids, and then get each message separately. There is no way around that, sadly. You can bring down the total amount of requests from `1 + N of messages` to 2 if you get all the messages in a [**batch request**](https://stackoverflow.com/questions/24562981/bulk-fetching-emails-in-the-new-gmail-api). – Tholle Sep 14 '17 at 07:28
  • 1
    @Tholle good answer – ReyAnthonyRenacia Sep 14 '17 at 07:35
  • 2
    Thanks @Tholle I figured that, was just hoping the documentation was right ;) – Neurus Sep 15 '17 at 18:21
  • Yes, apparently the documentation is incorrect. – Shmuel Kamensky Feb 01 '19 at 15:41

1 Answers1

0
gmail.users.messages.get({
auth: auth,
userId: 'me',
id: messageid,
format: "raw"
}, function (err, response) { 
});

You have to call the above api with each messageid. The response will be raw data for corresponding email

Shanavas VH
  • 153
  • 2
  • 11