Google Translator Toolkit API 错误(“Multipart must have Atom and media part") [英] Google Translator Toolkit API Error ("Multipart must have Atom and media part")
问题描述
我尝试通过 API 将文档(srt 字幕)上传到 Google Translator Toolkit.但是我收到一个错误:Multipart must have Atom and media part".怎么了?
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?
我的要求:
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
Google 翻译工具包数据 API 参考指南 v1 的链接.0
推荐答案
HTTP/1.1 规范 指出应该有一个空行分隔标头和正文.
The HTTP/1.1 specification states that there should be an empty line separating the headers and the body.
请求(第 5 节)和响应(第 6 节)消息使用 RFC 822 [9] 的通用消息格式来传输实体(消息的有效负载).两种类型的消息都包含一个起始行、零个或多个头字段(也称为头")、一个空行(即在 CRLF 之前没有任何内容的行)指示头字段的结尾,可能还有一个消息正文.
Request (section 5) and Response (section 6) messages use the generic message format of RFC 822 [9] for transferring entities (the payload of the message). Both types of message consist of a start-line, zero or more header fields (also known as "headers"), an empty line (i.e., a line with nothing preceding the CRLF) indicating the end of the header fields, and possibly a message-body.
您的请求应如下所示:
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--
这篇关于Google Translator Toolkit API 错误(“Multipart must have Atom and media part")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!