2016-02-19 33 views
2

我正嘗試使用Google Groups Migration API向Google Group添加條目。根據文件我使用這個網址:Google Group API媒體上傳的正確電子郵件數據

https://www.googleapis.com/upload/groups/v1/groups/groupId/archive?uploadType=media 

我正在提供auth令牌正確我認爲(得到過去HTTP 401錯誤)。現在我得到http 500,內部服務器錯誤。我的HTTP頭:

Content-Length: 291 
Content-Type: message/rfc822 

下面作爲一個平原RFC822類型的消息,我可以使數據:

From: "John Doe" <[email protected]> 
To: "Jane Doe" <[email protected]> 
Subject: forward test 
MIME-Version: 1.0 
Date: Fri, 19 Feb 2016 08:03:00 -0800 
Content-Type: message/rfc822 

This is the first line of the forward test. 

我有一個Gmail中的文件夾創建郵件一些其他的代碼,工作正常。爲此,我做「uploadType = multipart」,並以json格式創建我的數據。我也嘗試過爲羣組做這些,但沒有運氣。有任何想法嗎?

回答

2

請求的Content-Typemessage/rfc822像你說的,但你的消息的實際純文本部分是不是:

Content-Type: text/plain; charset="UTF-8" 
MIME-Version: 1.0 
Content-Transfer-Encoding: 7bit 
To: [email protected] 
From: [email protected] 
Subject: Subject Text 

The actual message text goes here 
+0

我覺得我做的事情是正確的。我提供了一個「message/rfc822」的大量數據。這又有多個消息部分,可以是文本,HTML等。請參閱此Google文檔:https://developers.google.com/gmail/api/guides/uploads#simple。我應該如何代替「電子郵件消息數據」?無論如何,我嘗試將第一個內容類型更改爲message/rfc822,但仍然失敗。 json響應是「後端錯誤」。有更好的例子我可以遵循嗎? –

+0

@JeffMcKay我明白了。我不知道,說實話。 '電子郵件消息數據'可能看起來像上面的例子,其餘的應該像你鏈接的例子。 – Tholle

+0

@Tholle http://stackoverflow.com/questions/35863352/storing-gmail-body-in-mysql-error – m2j