Google Translator Toolkit API 错误(“Multipart 必须具有 Atom 和媒体部分”)
我尝试通过 API 将文档(srt 字幕)上传到 Google Translator Toolkit。 但我收到一个错误:“Multipart 必须有 Atom 和媒体部分”。怎么了?
我的请求:
POST /toolkit/feeds/documents HTTP/1.1
Host: translate.google.com
GData-Version: 1.0
Authorization: GoogleLogin Auth=[myauth]
Content-Length: 404
Content-Type: multipart/related; boundary=SKYqYanmBJWCtDU
Slug: test.srt
--SKYqYanmBJWCtDU
Content-Type: application/atom+xml; charset=UTF-8
<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gtt="http://schemas.google.com/gtt/2009/11">
<title>test</title>
<gtt:sourceLanguage>en</gtt:sourceLanguage>
<gtt:targetLanguage>ru</gtt:targetLanguage>
</entry>
--SKYqYanmBJWCtDU
Content-Type: application/x-subrip
data
--SKYqYanmBJWCtDU--
答案:
HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=UTF-8
Date: Mon, 21 Feb 2011 18:20:24 GMT
Expires: Mon, 21 Feb 2011 18:20:24 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Connection: close
Transfer-Encoding: chunked
27
Multipart must have Atom and media part
0
I try upload document (srt subtitles) to Google Translator Toolkit via API.
But I get an error: "Multipart must have Atom and media part". What's wrong?
My request:
POST /toolkit/feeds/documents HTTP/1.1
Host: translate.google.com
GData-Version: 1.0
Authorization: GoogleLogin Auth=[myauth]
Content-Length: 404
Content-Type: multipart/related; boundary=SKYqYanmBJWCtDU
Slug: test.srt
--SKYqYanmBJWCtDU
Content-Type: application/atom+xml; charset=UTF-8
<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gtt="http://schemas.google.com/gtt/2009/11">
<title>test</title>
<gtt:sourceLanguage>en</gtt:sourceLanguage>
<gtt:targetLanguage>ru</gtt:targetLanguage>
</entry>
--SKYqYanmBJWCtDU
Content-Type: application/x-subrip
data
--SKYqYanmBJWCtDU--
Answer:
HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=UTF-8
Date: Mon, 21 Feb 2011 18:20:24 GMT
Expires: Mon, 21 Feb 2011 18:20:24 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Connection: close
Transfer-Encoding: chunked
27
Multipart must have Atom and media part
0
Link to Google Translator Toolkit Data API Reference Guide v1.0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HTTP/1.1 规范 规定应该有一个空行将标题和正文分开。
您的请求应如下所示:
The HTTP/1.1 specification states that there should be an empty line separating the headers and the body.
Your request should look like this: