I’m working with Zend Framework’s GData library to upload files to Google Docs. When I try to run my upload script, I keep getting this fatal error:
PHP Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 415
Content-Type application/x-www-form-urlencoded is not a valid input type.' in C:\...\Zend\Gdata\App.php:700
This happens even when I try uploading simple text files, so it’s not a file type issue. I’ve been searching for solutions but can’t find anything that works. Has anyone encountered this problem before? What could be causing the content type to be rejected by the Google Docs API when using Zend_GData?
HTTP 415 means the server can’t handle the media format you’re sending. Usually happens when your request body encoding doesn’t match what Google Docs API expects. You need to use the resumable upload protocol for document uploads, not a standard POST. Check your Zend_GData setup - make sure you’ve got $docs = new Zend_Gdata_Docs($client) configured right, then use uploadFile with the correct MIME type. Bet your request is getting encoded as form data when it should be raw file content.
This happens when the request gets mangled during transmission. Zend_GData sometimes defaults to form-encoded requests if you don’t explicitly set the upload method. Call $service->setMajorProtocolVersion(3) before uploading - it forces the library to use the proper document upload endpoint instead of the old form-based one. Also check that your auth token has the right scope permissions for document uploads. I spent hours debugging this exact same thing last year. Turned out my OAuth scope was read-only, so the API rejected uploads with confusing error messages.
i had the same prob. you gotta set the content-type header first, otherwise it gets the wrong type. just use $client->setHeaders('Content-Type', 'text/plain') and it should work fine!