google-admin-sdk - 使用 Google Groups Migration API 时获取 500 "Backend Error"

标签 google-admin-sdk

我正在尝试用 Python 编写一个应用程序,以允许用户将他们的 LISTSERV 存档迁移到我们域的 Google 网上论坛。尝试调用 archive.insert ( https://developers.google.com/admin-sdk/groups-migration/v1/reference/archive/insert ) 时,我收到 HttpError 500“后端错误”。

我正在这样阅读文件:

import mailbox
mailbox.mbox('path/to/archive')

当遍历 mbox 对象中的结果消息时,调用 .as_string() 函数会产生如下结果:

Date: Mon, 10 Feb 2014 10:58:41 -0600
Reply-To: Bob's test list <BOB@LISTSERV.DOMAIN.COM>,
 Bob Boberson <bob@EXCHANGE.DOMAIN.COM>
Sender: Bob's test list <BOB@LISTSERV.DOMAIN.COM>
From: Bob Boberson <bob@EXCHANGE.DOMAIN.COM>
Subject: blah blah blah
Mime-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="UTF-8"
Message-ID: <6949565692507828.WA.bobexchange.domain.com@listserv.domain.com>


Test message.

这里的一些问题提到通过确保 Message-ID 的格式正确来避免后端错误。但是,此特定消息的消息 ['Message-ID'] 导致 <6949565692507828.WA.bobexchange.domain.com@listserv.domain.com>,所以我不确定 Message-ID 是这里的问题。

我正在尝试像这样调用插入:

stream = StringIO.StringIO()
stream.write(msg.as_string())
media = apiclient.http.MediaIoBaseUpload(stream, mimetype='message/rfc822')
result = migration_api.archive().insert(groupId=group_email, media_body=media).execute()

有什么想法吗?提前致谢:)

更新

根据 Jay 在评论中的建议,我设置了 httplib2.debuglevel = 1。这是我尝试迁移同一封电子邮件的日志中的结果:

send: 'POST /upload/groups/v1/groups/group-name%40lists.domain.com/archive?uploadType=media&alt=json HTTP/1.1\r\nHost: www.googleapis.com\r\ncontent-length: 711\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\nuser-agent: google-api-python-client/1.4.0 (gzip)\r\ncontent-type: message/rfc822\r\nauthorization: Bearer *******\r\n\r\nDate: Mon, 10 Feb 2014 10:58:41 -0600\nReply-To: Bob\'s test list <GROUP-NAME@LISTSERV.DOMAIN.COM>,\n Bob Boberson <bob@EXCHANGE.DOMAIN.COM>\nSender: Bob\'s test list <bob@LISTSERV.DOMAIN.COM>\nFrom: Bob Boberson <bob@EXCHANGE.DOMAIN.COM>\nSubject: blah blah blah\nMime-Version: 1.0\nContent-Transfer-Encoding: quoted-printable\nContent-Type: text/plain; charset="UTF-8"\nMessage-ID: <6949565692507828.WA.bobexchange.domain.com@listserv.domain.com>\n\n\nTest message.'

reply: 'HTTP/1.1 500 Internal Server Error\r\n'

header: X-GUploader-UploadID: *****
header: Vary: Origin
header: Vary: X-Origin
header: Content-Type: application/json; charset=UTF-8
header: Content-Length: 177
header: Date: Wed, 23 Mar 2016 21:10:20 GMT
header: Server: UploadServer
header: Alternate-Protocol: 443:quic,p=1
header: Alt-Svc: quic=":443"; ma=2592000; v="31,30,29,28,27,26,25"

更新(带解决方案)

原来这是一个权限问题:在进行全域服务帐户路由时,一定要模拟拥有该组的用户。 FWIW,恕我直言,Groups Migration API 的错误消息需要更明确地说明问题所在。 “后端错误”非常笼统。弄清楚这一点就像用棍子戳问题直到它起作用。

最佳答案

原来这是一个权限问题:在进行全域服务帐户路由时,一定要模拟拥有该组的用户。 FWIW,恕我直言,Groups Migration API 的错误消息需要更明确地说明问题所在。 “后端错误”非常笼统。弄清楚这一点就像用棍子戳问题直到它起作用。

关于google-admin-sdk - 使用 Google Groups Migration API 时获取 500 "Backend Error",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36163375/

相关文章:

google-admin-sdk - 目录 API,客户更新/补丁失败,错误为 "Invalid Customer language"

google-apps-script - 目录查询仅返回 100 个用户

node.js - 尝试访问目录 api 时无权访问此资源/api

javascript - 将两个域上的用户的 Google Apps 目录拉入同一个电子表格中

python - 将 Argparse 与 Google Admin API 结合使用

python - 在 Admin SDK 中使用 Google Directory API 进行 Google 身份验证的正确方法是什么?

java - token 响应异常 : 401 Unauthorized Exception when trying to access Admin SDK Google API.

oauth-2.0 - 支持服务帐户 OAuth2 方案

google-admin-sdk - 是否有适用于 Google Directory API 的沙箱