user.messages.get responding invalid ID

3.1k views Asked by At

when attempting to test out the api explorer for user.messages: get I have been getting an invalid message ID response.

I am getting the message ID from a recent email in my inbox sent to me, and removed the <> from either ends.

response:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "invalidArgument",
    "message": "Invalid id value"
   }
  ],
  "code": 400,
  "message": "Invalid id value"
 }
}

I am a bit confused as I am using the powershell module gshell and noticed that the same messageID worked in my commands but returned invalid id value in the api explorer.

edit: if I do a inbox search for rfc822msgid:[messageID] it returns the correct message

2

There are 2 answers

2
Tholle On

You should not use the rfc822msgid, but the Gmail API message id. Try to list messages and use the id you get from that when getting the message.

0
Shanavas VH On

First you have to call the users.messages.list api. It will give a list of messageids. Then we have to call users.message.get api with each messageid to fetch the mail content. You can query the mails with advanced search options provided by Gmail API.