PHP Google Drive file upload fails with HTTP 400 error

I’m working on a web application that needs to upload files to Google Drive using PHP. I’m using the Zend Gdata library but running into issues. Every time I try to upload a document, I get an HTTP 400 error.

Here’s my current implementation:

$serviceName = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
$httpClient = Zend_Gdata_ClientLogin::getHttpClient($userEmail, $password, $serviceName);
$docsService = new Zend_Gdata_Docs($httpClient);

$uploadedFile = $docsService->uploadFile(
    $_FILES['document']['tmp_name'], 
    $_FILES['document']['name'], 
    null, 
    Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI
);

The error message I’m seeing is:

PHP Fatal error: Uncaught exception ‘Zend_Gdata_App_HttpException’ with message ‘Expected response code 200, got 400 Inconsistent repeating query parameter’ in C:…\Zend\Gdata\App.php:700

Has anyone encountered this before? What could be causing the inconsistent query parameter issue?

had a similar issue before. double-check your feed URI; might be a problem with the trailing slash. also, ensure your mime type is set properly - that can trigger a 400 error too. hope this helps!

This takes me back to wrestling with an old document management system. That HTTP 400 “inconsistent repeating query parameter” error usually happens when you’re sending auth credentials multiple times in the same request. I fixed it by explicitly setting the auth method before uploading. Try $httpClient->setAuthSubToken($token) if you’re using AuthSub, or check that you’re not accidentally initializing the client twice with different credentials. Also verify your $_FILES['document']['tmp_name'] has a valid file path - I’ve seen empty or broken file references make the library add malformed parameters to the request URL.

The Zend Gdata library is pretty outdated now and Google killed the Documents List API it uses. I hit the same HTTP 400 errors trying to keep legacy code running with this thing. That “inconsistent repeating query parameter” error happens when the library sends duplicate parameters in the URL - Google’s servers just reject it. Don’t bother trying to fix this deprecated mess. Just migrate to Google Drive API v3 with their official PHP client. OAuth2 authentication is way cleaner and you won’t deal with these compatibility headaches. Yeah, the migration looks scary at first, but it’s worth it for something that actually works long-term.

I hit this exact error with Zend Gdata file uploads about two years back. The auth token was getting passed in both the Authorization header AND as a query parameter - that’s what caused the duplicate parameter error. Fixed it by clearing the HTTP client’s parameter cache before uploading. Try $httpClient->resetParameters() right before your uploadFile call. Also double-check your temp file path is accessible and the file isn’t corrupted. I’ve seen file permission issues throw similar HTTP 400 errors that weren’t obvious from the error message.

check if your php version matches the zend library ur using. version mismatches can cause weird parameter duplication. also clear any cached auth tokens - corrupted ones mess up request formatting.

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.