Jeff McKay
Jeff McKay

Reputation: 295

Getting http 500 backend error when posting to Gmail API

I am using the Gmail API to put messages into a Google Apps email account. I use the OAuth 2.0 authentication protocol with a service account. This is more or less working fine. One of our customers has asked us to put messages directly into a Google Vault. I don't see a Vault API, but I did find this information related to the "insert" method (which is what we use to add messages to a normal account):

parameter "deleted" (boolean): Mark the email as permanently deleted (not TRASH) and only visible in Google Apps Vault to a Vault administrator. Only used for Google Apps for Work accounts.

When I do this, some messages are accepted, but frequently I get http error 500 in response to the POST. The error text says "Backend Error". I thought the pattern was that the first time the message was posted, it would work, but the second time would generate the error. Therefore I was thinking it was a duplicate check issue. However I now see some examples of messages that fail immediately. The POST url looks like this:

https://www.googleapis.com/upload/gmail/v1/users/[email protected]/messages?uploadType=multipart&internalDateSource=dateHeader&deleted=true&access_token=ABC...

As I mentioned, the same message to the same url (without deleted=true) will always work. Any ideas what is causing the error?

Upvotes: 1

Views: 490

Answers (2)

Giulio
Giulio

Reputation: 1

I'm using the import api method and the backendError seems to be related to filters/policies. For example we asked Google to reject messages with xls and macros and we get the error on mail with that kind of attachment

Upvotes: 0

Mike Rimov
Mike Rimov

Reputation: 1

Was just fighting this issue myself. Apparently the error has something to do if the message is compatible with the Google vault retention policies:

If I turn on a default policy of "Retain everything" then I've been able to get the messages to import correctly. HTH!

Upvotes: 0

Related Questions