电子邮件迁移API v2。多部分插入返回503

时间:2014-09-08 17:49:40

标签: google-api google-api-ruby-client google-email-migration

我使用google客户端api为ruby版本0.7.1测试电子邮件迁移API V2 对于分段上传,我总是从服务器获得此响应:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "backendError",
    "message": "Backend Error"
   }
  ],
  "code": 503,
  "message": "Backend Error"
 }
}

这是我的代码:

client = Google::APIClient.new(
  :application_name => 'My app',
  :application_version => '1.1.0'
)
#auth code skipped

migration = client.discovered_api('admin', 'email_migration_v2')

file = {"isInbox" => true}
mail =  StringIO.new "Date: Wed, 03 Jan 2013 02:56:03 -0800
From: admin@example.org
To: liz@example.com
Subject: Hello World!
MIME-Version: 1.0
Content-Type: text/html; charset=windows-1252
Content-transfer-encoding: 8bit

And I think to myself... What a wonderful world!"

media = Google::APIClient::UploadIO.new(mail, 'message/rfc822')

client.execute!(:api_method=> migration.mail.insert,
  :media => media,
  :body_object => file,
  parameters: {
    'userKey' => "name@domain.com",
    'uploadType' => 'multipart',
})

一些日志信息

DEBUG 18:58:13 rails [pid = 6311]:Google :: APIClient ::请求发送API请求帖子https://www.googleapis.com/upload/email/v2/users/name@domain.com/mail?uploadType=multipart {“User-Agent”=>“我的app / 1.1.0 google- api-ruby-client / 0.7.1 Mac OS X / 10.9.4 \ n(gzip)“,”Content-Type“=>”multipart / related; boundary = ----------- RubyApiMultipartPost “,”Content-Length“=>”682“,”Accept-Encoding“=>”gzip“,”授权“=>”Bearer xxxxx“,”Cache-Control“=>”no-store“ }

POST BODY:

DEBUG 18:58:13 rails [pid=6311]: -------------RubyApiMultipartPost
Content-Disposition: form-data; name=""; filename="file.json"
Content-Length: 16
Content-Type: application/json
Content-Transfer-Encoding: binary

{"isInbox":true}
-------------RubyApiMultipartPost
Content-Disposition: form-data; name=""; filename="local.path"
Content-Length: 249
Content-Type: message/rfc822
Content-Transfer-Encoding: binary

Date: Wed, 03 Jan 2013 02:56:03 -0800
From: admin@example.org
To: liz@example.com
Subject: Hello World!
MIME-Version: 1.0
Content-Type: text/html; charset=windows-1252
Content-transfer-encoding: 8bit

And I think to myself... What a wonderful world!
-------------RubyApiMultipartPost--

请帮助我理解为什么谷歌会回复503.我如何解决它。 我确信我没有达到API配额。

更新1:

看起来Content-Disposition标头是503错误的原因,因为没有它上传工作正常!

0 个答案:

没有答案
相关问题