本文介绍了获得500个“后端错误";使用Google Groups Migration API时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am attempting to write an app in Python to allow users to migrate their LISTSERV archives to Google Groups for our domain. When attempting to call archive.insert (https://developers.google.com/admin-sdk/groups-migration/v1/reference/archive/insert), I receive an HttpError 500 "Backend Error".

我正在像这样阅读档案:

I am reading in the archive like so:

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

遍历mbox对象中的结果消息时,调用.as_string()函数将导致如下所示:

When iterating through the resulting messages in the mbox object, calling the .as_string() function results in something like this:

Date: Mon, 10 Feb 2014 10:58:41 -0600
Reply-To: Bob's test list <[email protected]>,
 Bob Boberson <[email protected]>
Sender: Bob's test list <[email protected]>
From: Bob Boberson <[email protected]>
Subject: blah blah blah
Mime-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="UTF-8"
Message-ID: <[email protected]>


Test message.

这里有些问题提到通过确保Message-ID的格式正确来避免后端错误.但是,此特定邮件的message ['Message-ID']导致< [email protected]>,因此我不确定Message-ID是这里的问题.

Some questions here mention avoiding backend errors by ensuring that the Message-ID is in the correct format. However, message['Message-ID'] for this particular message results in <[email protected]>, so I'm not sure Message-ID is the issue here.

我正试图像这样调用插入

I am attempting to call insert like so:

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()

有什么想法吗?在此先感谢:)

Any ideas? Thanks in advance :)

更新

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

According to Jay's suggestion in the comments, I have set httplib2.debuglevel = 1. Here is the result in my logs of attempting to migrate the same email:

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 <[email protected]>,\n Bob Boberson <[email protected]>\nSender: Bob\'s test list <[email protected]>\nFrom: Bob Boberson <[email protected]>\nSubject: blah blah blah\nMime-Version: 1.0\nContent-Transfer-Encoding: quoted-printable\nContent-Type: text/plain; charset="UTF-8"\nMessage-ID: <[email protected]>\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,恕我直言,有关组迁移API的错误消息需要更清楚地说明问题所在. 后端错误"非常通用.弄清楚这一点就像用棍子戳问题直到解决.

It turns out this was a permissions issue: When going the domain-wide service account route, be sure to impersonate the user who owns the group. FWIW, IMHO, the error messages for the Groups Migration API need to be a little more explicit about what the problem is. "Backend Error" is horribly generic. Figuring this out was like poking at the problem with a stick until it works.

推荐答案

事实证明这是一个权限问题:在使用域范围内的服务帐户路由时,请确保模拟拥有该组的用户. FWIW,恕我直言,有关组迁移API的错误消息需要更清楚地说明问题所在. 后端错误"非常通用.弄清楚这一点就像用棍子戳问题直到解决.

It turns out this was a permissions issue: When going the domain-wide service account route, be sure to impersonate the user who owns the group. FWIW, IMHO, the error messages for the Groups Migration API need to be a little more explicit about what the problem is. "Backend Error" is horribly generic. Figuring this out was like poking at the problem with a stick until it works.

这篇关于获得500个“后端错误";使用Google Groups Migration API时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 21:05