I am using Zend GData to upload documents to Google docs.
The code works fine, except once in a while, it raises exception:
400 Bad Request - Unable to convert document.
This is an intermittent issue. So I believe the code is not a problem.
try {
$test=$sharedocs->insertEntry($dataShare, $uri, 'Zend_Gdata_Entry',$header);
} catch (Exception $e ) {
echo $e->getMessage();
exit();
}
Here is the exception
Zend_Gdata_App_HttpException Object ( [_httpClientException:protected] => [_response:protected] => Zend_Http_Response Object ( [version:protected] => 1.1 [code:protected] => 400 [message:protected] => Bad Request [headers:protected] => Array ( [Content-type] => text/html; charset=UTF-8 [Date] => Fri, 14 Dec 2012 23:32:18 GMT [Expires] => Fri, 14 Dec 2012 23:32:18 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 ) [body:protected] => Unable to convert document. ) [_previous:Zend_Exception:private] => [message:protected] => Expected response code 200, got 400 Unable to convert document. [string:Exception:private] => [code:protected] => 0 [file:protected] => /usr/local/zend/share/ZendFramework/library/Zend/Gdata/App.php [line:protected] => 714 [trace:Exception:private] => Array ( [0] => Array ( [file] => /usr/local/zend/share/ZendFramework/library/Zend/Gdata.php [line] => 219 [function] => performHttpRequest [class] => Zend_Gdata_App [type] => -> [args] => Array ( [0] => POST [1] => https://docs.google.com/feeds/documents/private/full [2] => Array ( [0] => Content-Type: multipart/related; boundary="END_OF_PART" [1] => Slug: test.doc [2] => Content-Type: application/msword [3] => resourceId:4321 [x-http-method-override] => [authorization] => AuthSub token="xxxxx" ) [3] => Room for Debate (12345) [4] => application/atom+xml [5] => ) ) [1] => Array ( [file] => /usr/local/zend/share/ZendFramework/library/Zend/Gdata/App.php [line] => 905 [function] => performHttpRequest [class] => Zend_Gdata [type] => -> [args] => Array ( [0] => POST [1] => https://docs.google.com/feeds/documents/private/full [2] => Array ( [0] => Content-Type: multipart/related; boundary="END_OF_PART" [1] => Slug: test.doc [2] => Content-Type: application/msword [3] => resourceId:4321 [x-http-method-override] => ) [3] => Room for Debate (12345) [4] => application/atom+xml ) ) [2] => Array ( [file] => /usr/local/zend/share/ZendFramework/library/Zend/Gdata/App.php [line] => 980 [function] => post [class] => Zend_Gdata_App [type] => -> [args] => Array ( [0] => Room for Debate (12345) [1] => [2] => [3] => [4] => Array ( [0] => Content-Type: multipart/related; boundary="END_OF_PART" [1] => Slug: test.doc [2] => Content-Type: application/msword [3] => resourceId:4321 ) ) ) [3] => Array ( [file] => /var/www/GoogleFunctions.php [line] => 90 [function] => insertEntry [class] => Zend_Gdata_App [type] => -> [args] => Array ( [0] => Room for Debate (12345) [1] => [2] => Zend_Gdata_Entry [3] => Array ( [0] => Content-Type: multipart/related; boundary="END_OF_PART" [1] => Slug: test.doc [2] => Content-Type: application/msword [3] => resourceId:4321 ) ) ) [4] => Array ( [file] => /var/www/myPaper.php [line] => 342 [function] => createNewDoc [args] => Array ( [0] => Room for Debate (12345) [1] => Zend_Gdata_Docs Object ( [_defaultPostUri:protected] => https://docs.google.com/feeds/documents/private/full [_registeredPackages:protected] => Array ( [0] => Zend_Gdata_Docs [1] => Zend_Gdata_Kind [2] => Zend_Gdata_Extension [3] => Zend_Gdata [4] => Zend_Gdata_App_Extension [5] => Zend_Gdata_App ) [_httpClient:protected] => Zend_Gdata_HttpClient Object ( [_authSubPrivateKeyId:Zend_Gdata_HttpClient:private] => [_authSubToken:Zend_Gdata_HttpClient:private] => 1/xxxxx [_clientLoginToken:Zend_Gdata_HttpClient:private] => [_clientLoginKey:Zend_Gdata_HttpClient:private] => [_streamingRequest:protected] => [config:protected] => Array ( [maxredirects] => 0 [strictredirects] => 1 [useragent] => Zend_Framework_Gdata/1.11.12 [timeout] => 10 [adapter] => Zend_Http_Client_Adapter_Socket [httpversion] => 1.1 [keepalive] => [storeresponse] => 1 [strict] => 1 [output_stream] => [encodecookies] => 1 [rfc3986_strict] => ) [adapter:protected] => Zend_Http_Client_Adapter_Socket Object ( [socket:protected] => [connected_to:protected] => Array ( [0] => [1] => ) [out_stream:protected] => [config:protected] => Array ( [persistent] => [ssltransport] => ssl [sslcert] => [sslpassphrase] => [sslusecontext] => [maxredirects] => 0 [strictredirects] => 1 [useragent] => Zend_Framework_Gdata/1.11.12 [timeout] => 10 [httpversion] => 1.1 [keepalive] => [storeresponse] => 1 [strict] => 1 [output_stream] => [encodecookies] => 1 [rfc3986_strict] => ) [method:protected] => POST [_context:protected] => Resource id #10 ) [uri:protected] => Zend_Uri_Http Object ( [_username:protected] => [_password:protected] => [_host:protected] => docs.google.com [_port:protected] => 443 [_path:protected] => /feeds/documents/private/full [_query:protected] => [_fragment:protected] => [_regex:protected] => Array ( [escaped] => %[[:xdigit:]]{2} [unreserved] => [A-Za-z0-9-_.!~*'()\[\]] [segment] => (?:%[[:xdigit:]]{2}|[A-Za-z0-9-_.!~*'()\[\]:@&=+$,;])* [path] => (?:\/(?:(?:%[[:xdigit:]]{2}|[A-Za-z0-9-_.!~*'()\[\]:@&=+$,;])*)?)+ [uric] => (?:%[[:xdigit:]]{2}|[A-Za-z0-9-_.!~*'()\[\];\/?:@&=+$,]) ) [_scheme:protected] => https ) [headers:protected] => Array ( [user-agent] => Array ( [0] => User-Agent [1] => MyCompany-MyApp-1.0 Zend_Framework_Gdata/1.11.12 ) [content-type] => Array ( [0] => Content-Type [1] => application/atom+xml ) [slug] => Array ( [0] => Slug [1] => test.doc ) [resourceid] => Array ( [0] => resourceId [1] => 4321 ) [authorization] => Array ( [0] => authorization [1] => AuthSub token="1/xxxxx" ) [accept-encoding] => Array ( [0] => Accept-encoding [1] => identity ) [content-length] => Array ( [0] => Content-Length [1] => 273 ) ) [method:protected] => POST [paramsGet:protected] => Array ( ) [paramsPost:protected] => Array ( ) [enctype:protected] => application/atom+xml [raw_post_data:protected] => Room for Debate (12345) [auth:protected] => [files:protected] => Array ( ) [body_field_order:protected] => Array ( [service] => SCALAR ) [cookiejar:protected] => [last_request:protected] => POST /feeds/documents/private/full HTTP/1.1 Host: docs.google.com Connection: close User-Agent: MyCompany-MyApp-1.0 Zend_Framework_Gdata/1.11.12 Content-Type: application/atom+xml Slug: test.doc resourceId: 4321 authorization: AuthSub token="1/xxxxx" Accept-encoding: identity Content-Length: 273 Room for Debate (12345) [last_response:protected] => Zend_Http_Response Object ( [version:protected] => 1.1 [code:protected] => 400 [message:protected] => Bad Request [headers:protected] => Array ( [Content-type] => text/html; charset=UTF-8 [Date] => Fri, 14 Dec 2012 23:32:18 GMT [Expires] => Fri, 14 Dec 2012 23:32:18 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 ) [body:protected] => Unable to convert document. ) [redirectCounter:protected] => 0 [_unmaskStatus:protected] => [_queryBracketsEscaped:protected] => 1 ) [_majorProtocolVersion:protected] => 1 [_minorProtocolVersion:protected] => [_useObjectMapping:protected] => 1 ) ) ) ) [previous:Exception:private] => )
Ohh, so I answered somebodys question on same lines and forgot to put it on my question. :D
(https://stackoverflow.com/a/14290948/1736522) Google Docs/Drive API does not permit a new document to be inserted into a new Google account