我正在尝试使用 C# Google Groups Migration API,但运气不佳。
我有以下代码:
var body =
@"Date: 16 Jul 07 10:12 GMT
From: samplesender@example.com
To: samplegroup@googlegroups.com
This is the body of the migrated email message.
";
var bytes = ASCIIEncoding.ASCII.GetBytes(body);
var messageStream = new MemoryStream(bytes);
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets { ClientId = "<insert client id here>", ClientSecret = "<insert client secret here>" },
new[] { "https://www.googleapis.com/auth/apps.groups.migration" },
"user",
CancellationToken.None,
new FileDataStore("GroupsMigration.Auth.Store")).Result;
var service = new GroupsMigrationService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "group migration application"
});
var request = service.Archive.Insert("<insert valid group email here>", messageStream, "message/rfc822");
IUploadProgress uploadStatus = request.Upload();
if (uploadStatus.Exception != null)
{
Console.WriteLine(uploadStatus.Exception.ToString());
}
我不断收到以下异常:
The service groupsmigration has thrown an exception: Google.GoogleApiException: Google.Apis.Requests.RequestError
Unable to parse the raw message [400]
Errors [
Message[Unable to parse the raw message] Location[ - ] Reason[invalid] Domain[global]
]
根据 Groups Migration API 文档(https://developers.google.com/admin-sdk/groups-migration/v1/reference/archive/insert参见页面底部的 responseCode 部分),它表明消息我正在尝试迁移被拒绝为格式错误。我尝试了许多不同的消息,但总是收到相同的错误 -> 无法解析原始消息 [400]。
有没有人发现 Google Groups Migration 接受并愿意分享的消息?还有什么我做错了吗?
任何帮助感激不尽!