Google Translator Toolkit API 错误(“Multipart 必须具有 Atom 和媒体部分”)

发布于 2024-10-18 08:19:43 字数 1399 浏览 4 评论 0原文

我尝试通过 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

Google 翻译工具包数据 API 参考指南 v1.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

养猫人 2024-10-25 08:19:43

HTTP/1.1 规范 规定应该有一个空行将标题和正文分开。

请求(第 5 节)和响应(第 6 节)消息使用 RFC 822 [9] 的通用消息格式来传输实体(消息的有效负载)。两种类型的消息均由起始行、零个或多个标头字段(也称为“标头”)、指示标头字段结束的空行(即,CRLF 之前没有任何内容的行)以及可能的消息正文。

您的请求应如下所示:

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

The HTTP/1.1 specification states that there should be an empty line separating the headers and the body.

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.

Your request should look like this:

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--
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文