I am trying to send a en email with an attachment via the GmailV1 API. However it just isn't working due to Missing Draft Message errors.
According to RubyDoc I tried to create a draft message as follows:
The GmailV1:GmailService.create_user_draft() methods takes in an identifier and a draft_object (accepting 'me' for the authorized user). A draft object (Google::Apis::GmailV1::Draft) takes a message in the form of Google::Apis::GmailV1::Message which in turn takes a payload in the form of Google::Apis::GmailV1::MessagePart which has the desired filename method.
So I ran this code:
##assume client is an authorized instance of Google::Apis::GmailV1:GmailService
msg_part = Google::Apis::GmailV1::MessagePart.new(filename: 'path/to/file')
msg = Google::Apis::GmailV1::Message.new(payload: msg_part)
draft = Google::Apis::GmailV1::Draft.new(message: msg)
client.create_user_draft('me', draft)
>> Google::Apis::ClientError: invalidArgument: Missing draft message
How Come?
Versions:
google-api-client 0.9.9
googleauth 0.5.1
ruby 2.3.1p112