2012-03-07 108 views
0

我已經看到了這個問題/答案這是與我相似:谷歌Apps電子郵件遷移API錯誤「必須有原子和媒體部分」

Google Translator Toolkit API Error ("Multipart must have Atom and media part")

但是建議的解決方案是與我無關。我正在嘗試使用Google電子郵件遷移API並向用戶收件箱發送消息。我已成功通過身份驗證。對POST的響應是HTTP錯誤400錯誤請求,並且html錯誤是「必須有原子和媒體部分」。下面是我發送的http頭和數據。我認爲谷歌在解析不同部分時遇到了一些問題,但我看不到我可能會做錯什麼。

HTTP標頭:

Content-Length: 1235 
Content-Type: multipart/related; boundary=Part_0_25934938.1266495790627 
Authorization: GoogleLogin auth=DQAAAPUAAAB7vtNS... 

HTTP數據(注:始於CR/LF):

--Part_0_25934938.1266495790627 
Content-Type: application/atom+xml 

<?xml version="1.0"; encoding="UTF-8"?> 
<entry xmlns="http://www.w3.org/2005/Atom" 
    xmlns:apps="http://schemas.google.com/apps/2006"> 
    <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/apps/2006#mailItem"/> 
    <atom:content xmlns:atom="http://www.w3.org/2005/Atom" type="message/rfc822"/> 
    <apps:mailItemProperty value="IS_INBOX"/> 
</entry> 

--Part_0_25934938.1266495790627 
Content-Type: message/rfc822 

MIME-Version: 1.0 
Received: by 10.216.170.147 with HTTP; Fri, 26 Mar 2010 12:54:28 -0700 (PDT) 
Date: Sat, 27 Mar 2010 03:54:28 +0800 
Delivered-To: [email protected] 
Message-ID: <203b3a4f1043461254v14855b71w9c[email protected]> 
Subject: hello multipart 
From: Elizabeth Bennet <[email protected]> 
To: Fitzwilliam Darcy <[email protected]> 
Content-Type: multipart/alternative; boundary=000e0cdf7740f8017e0482b9877a 

--000e0cdf7740f8017e0482b9877a 
Content-Type: text/plain; charset=ISO-8859-1 

howdy multipart! 

--000e0cdf7740f8017e0482b9877a 
Content-Type: text/html; charset=ISO-8859-1 

howdy multipart! 

--000e0cdf7740f8017e0482b9877a-- 

--Part_0_25934938.1266495790627-- 

回答

0

這種錯誤可能是由於無效的Content-Length即它是小於它所應該是和服務器無法解析消息的部分。

+0

我會再看看它,但我不認爲這是問題 - 我通過將所有內容寫入文件來創建發佈數據,然後重新打開該文件並獲取其長度,然後使用該數據內容長度。 – 2012-03-07 17:19:16

相關問題