2
votes

I am having a weird behaviour with the new Gmail UI update with the Users.drafts: send API.

(https://developers.google.com/gmail/api/v1/reference/users/drafts/send)

https://www.googleapis.com/upload/gmail/v1/users/me/drafts/send?uploadType=multipart

I do provide a payload when calling the API.

Example:

--foobar
Content-Type: application/json; charset=UTF-8
{
    "id":"r7236859678058445300","message": {"threadId":"1638e05ec3ad551b"}
}
-- foobar
Content-Type: message/rfc822

MIME-Version: 1.0
Date: Wed, 23 May 2018 13:22:22 -0400
Message-ID: <CAEygFSf=hnH-dTUeXDC3Z0FKDLB_C94ej4FNK- 
[email protected]>
Subject: Test
From: Tom <[email protected]>
To: Tom <[email protected]>
Content-Type: multipart/alternative; boundary="00000000000028c4a8056ce2c7eb"

--00000000000028c4a8056ce2c7eb
Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes

dsfsdfsdf

--00000000000028c4a8056ce2c7eb
Content-Type: text/html; charset="UTF-8"

<div dir="ltr">dsfsdfsdf</div>
--00000000000028c4a8056ce2c7eb--

-- foobar --

We have also tried using the draft.send with raw https://www.googleapis.com/upload/gmail/v1/users/me/drafts/send?format=raw

This works for us however, we are not able to send large attachments using this URL, that is why use the multipart.

When I use the API in the new Gmail UI and send the email to myself, I cannot retrieve the email message. It shows in my inbox but when I click on the message, I get an error saying, “The conversation that you requested could not be loaded”. However, when I switch back to the old Gmail UI I have no problem retrieving the message. The API works when sending email to other recipients.

I have tried this in the OAuth 2.0 playground and the Gmail API site to isolate the send API by sending the email to myself. I get the 200 response and the API have successfully sent the email. But, the same thing happens when I go to the new Gmail UI vs the old Gmail UI.

We are doing developement in the chrome extension.

I have no idea why this is happening. I am hoping someone could explain this to me.

Thank you for your help.

1
It would probably help the community if you added some relevant code,rainer
Today I found the same issue - but in my case all the draft message are showing error - Could not load and disappearing after few minutesSandeep Chikhale
This seems be duplicate of the following problem: stackoverflow.com/questions/50558425/…user2196351

1 Answers

0
votes

We figured out the issue. When you send a NEW email do not add the Thread Id just the draft Id.

--foobar
Content-Type: application/json; charset=UTF-8
{
    "id":"r7236859678058445300"
}

When reply or forward an email you add the thread Id

--foobar
Content-Type: application/json; charset=UTF-8
{
      "id":"r7236859678058445300","message": {"threadId":"1638e05ec3ad551b"}
}