0

I am able to send mails form gmail using oAuth in my application. When i am sending a mail with attachment sized about 6.5 MB getting 400 bad request error. This works perfectly for mail with small attachment.

Is there any configuration in gmail admin page to set max size of attachment ? Below is the response i am recieveing:

2016-05-25 04:45:35 ERROR dataPull:219 - sendMail: 400 Bad Request

<HTML>
<HEAD>
<TITLE>Bad Request</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Bad Request</H1>
<H2>Error 400</H2>
</BODY>
</HTML>
gSr
  • 116
  • 2
  • 8
  • You cannot use the standard metadata url when uploading attachments over a few mg in size, as you mentioned. I wrote a [tiny module](https://www.npmjs.com/package/gmail-api-create-message-body) for this in JavaScript that you might want to check out. – Tholle May 25 '16 at 14:37

1 Answers1

0

You can fix the 400 Bad Request by going to your domain's Admin Console, Manage API client access page under security and add the Client ID from the Developer Console, add the scopes needed for the Gmail API. Check the Delegation domain-wide authority to the service account. They work well for APIs that dont need a user or when you are using a Google Apps for Work domain and want delegation enabled for all the users in the domain.

As the document stated that If a request result in a new source is syntactically or semantically invalid, the server returns a 400 Bad Request HTTP status code and the source state remains unchanged.

Here's a related SO ticket whcih discuss about 400 Bad Request when sending email: Gmail api Sending email 400 bad request

Regarding the File size limit, Based from the Official Google Documentation, the maximum upload file size is the maximum amount of data you can store within method, you can make upload requests in any of the following ways:

Here's a SO ticket asking for size limit of email attachment: Gmail API - size limit batching of emails with attachments?

Community
  • 1
  • 1
Android Enthusiast
  • 4,826
  • 2
  • 15
  • 30