Google Apps电子邮件迁移API错误"必须包含原子和媒体部分"

时间:2012-03-07 00:37:38

标签: xml

我已经看过这个与我类似的问题/答案:

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

然而,建议的解决方案与我无关。我正在尝试使用Google电子邮件迁移API并将消息发布到用户收件箱。我已成功通过身份验证。对POST的响应是http错误400错误请求,并且html错误是“必须有原子和媒体部分”。下面是我发送的http标头和数据。我认为Google在解析不同部分时遇到了一些问题,但我看不出我的错误。

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: darcy@example.com
Message-ID: <203b3a4f1043461254v14855b71w9ce59e3abcf45962@mail.gmail.com>
Subject: hello multipart
From: Elizabeth Bennet <bennet@example.com>
To: Fitzwilliam Darcy <darcy@example.com>
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--

1 个答案:

答案 0 :(得分:0)

此错误可能是由于内容长度无效,即它应该小于应该的内容,并且服务器无法解析消息的各个部分。