Google Translator Toolkit API Error ("Multipart must have Atom and media part")

574 views Asked by At

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

1

There are 1 answers

0
Mark Basmayor On BEST ANSWER

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