Post Body:
Hello,
I’m experiencing persistent `400 Bad Request` errors with `INVALID_ARGUMENT` status when calling the `fileSearchStores.importFile` endpoint. Despite following the official API documentation format, all import attempts are failing.
### Error Details
**Error Response:**
{
“error”: {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
}
Endpoint:
POST https://generativelanguage.googleapis.com/v1beta/fileSearchStores/{storeId}:importFile?key={apiKey}
Request Body:
{
“fileName”: “files/{fileId}”
}
Example Request:
-
Store ID: fileSearchStores/see7contentstore-fodsm5fist43
-
File Name: files/hpkzpfjj5732
-
File URI: https://generativelanguage.googleapis.com/v1beta/files/hpkzpfjj5732
-
File State: ACTIVE (verified before import attempt)
What I’ve Verified
-
File Upload: Files are successfully uploaded to Gemini File Service -
File State: Files are confirmed in ACTIVE state before import attempts -
Store Format: Store ID is correctly formatted as fileSearchStores/{id} -
Request Format: Matches documentation - using fileName field with files/{id} format -
Store Verification: Store exists and is accessible (verified via GET request) -
API Key: Has proper permissions (file uploads work, store verification works)
What I’ve Tried
-
Standard Format: {“fileName”: “files/{id}”} -
Fails with 400 -
File ID Only: {“fileName”: “{id}”} -
Fails with 400 -
Full URI: {“fileName”: “https://generativelanguage.googleapis.com/v1beta/files/{id}”} -
Fails with 400 -
Snake Case Field: {“file_name”: “files/{id}”} -
Fails with 400 -
Store Verification: Store exists and is accessible -
Works -
File State Verification: Files are ACTIVE before import -
Confirmed
Code Context
I’m using direct REST API calls (not SDK) with the following implementation:
const importFileEndpoint = `https://generativelanguage.googleapis.com/v1beta/${normalizedStoreId}:importFile?key=${apiKey}\`;
const requestBody = { fileName: fileName }; // fileName is “files/{id}”
const response = await fetch(importFileEndpoint, {
method: ‘POST’,
headers: { ‘Content-Type’: ‘application/json’ },
body: JSON.stringify(requestBody),
});
Questions
-
Is there a known issue with the importFile endpoint returning 400 errors?
-
Are there any additional required fields or parameters not mentioned in the documentation?
-
Could this be related to the recent File Search Tool API changes (November 2025)?
-
Is there a difference in behavior between using the REST API directly vs. SDKs?
-
Are there any project-level or store-level settings that might affect importFile?
Environment
-
API Version: v1beta
-
Authentication: API Key (from Google AI Studio)
-
File Types: HTML files (text/html)
-
Store Location: Created via Google AI Studio
Additional Context
-
This started occurring recently (December 2025)
-
Files upload successfully but cannot be imported to stores
-
The error is consistent across all files and import attempts
-
No rate limiting errors (429) - specifically 400 INVALID_ARGUMENT
Any guidance or insights would be greatly appreciated. Thank you!