400 INVALID_ARGUMENT error when calling fileSearchStores.importFile - Request format appears correct per documentation

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:

What I’ve Verified

  1. :white_check_mark: File Upload: Files are successfully uploaded to Gemini File Service

  2. :white_check_mark: File State: Files are confirmed in ACTIVE state before import attempts

  3. :white_check_mark: Store Format: Store ID is correctly formatted as fileSearchStores/{id}

  4. :white_check_mark: Request Format: Matches documentation - using fileName field with files/{id} format

  5. :white_check_mark: Store Verification: Store exists and is accessible (verified via GET request)

  6. :white_check_mark: API Key: Has proper permissions (file uploads work, store verification works)

What I’ve Tried

  1. Standard Format: {“fileName”: “files/{id}”} - :cross_mark: Fails with 400

  2. File ID Only: {“fileName”: “{id}”} - :cross_mark: Fails with 400

  3. Full URI: {“fileName”: “https://generativelanguage.googleapis.com/v1beta/files/{id}”} - :cross_mark: Fails with 400

  4. Snake Case Field: {“file_name”: “files/{id}”} - :cross_mark: Fails with 400

  5. Store Verification: Store exists and is accessible - :white_check_mark: Works

  6. File State Verification: Files are ACTIVE before import - :white_check_mark: 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

  1. Is there a known issue with the importFile endpoint returning 400 errors?

  2. Are there any additional required fields or parameters not mentioned in the documentation?

  3. Could this be related to the recent File Search Tool API changes (November 2025)?

  4. Is there a difference in behavior between using the REST API directly vs. SDKs?

  5. 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!

Hi @Paul_Benati
Welcome to the Google AI Forum!!!

Could you please share steps to reproduce the issue along with a sample of the code that you are using? It helps us to reproduce and showcase to the appropriate teams.