Jon
Jon

Reputation: 247

user.messages.get responding invalid ID

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

Upvotes: 3

Views: 3501

Answers (2)

Shanavas VH
Shanavas VH

Reputation: 163

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.

Upvotes: 1

Tholle
Tholle

Reputation: 112867

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.

Upvotes: 0

Related Questions