# Gemini File Search: importFile (file-ID path) fails with 401 using API key

**URL:** <https://discuss.ai.google.dev/t/gemini-file-search-importfile-file-id-path-fails-with-401-using-api-key/170022>\
**Category:** Gemini API\
**Tags:** bug, api\
**Created:** [June 7, 2026, 6:57pm UTC](https://discuss.ai.google.dev/t/gemini-file-search-importfile-file-id-path-fails-with-401-using-api-key/170022 "2026-06-07T18:57:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Duy\_Tien](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/duy_tien/32/129912_2.png) [@Duy\_Tien](https://discuss.ai.google.dev/u/Duy_Tien)\
**Post date:** [June 7, 2026, 6:57pm UTC](https://discuss.ai.google.dev/t/gemini-file-search-importfile-file-id-path-fails-with-401-using-api-key/170022/1 "2026-06-07T18:57:35Z")

</div>

When using a **Gemini API key** (`x-goog-api-key`), the `fileSearchStores.importFile` method consistently returns:

```auto
{ "error": { "code": 401, "message": "The request does not have valid authentication credentials.", "status": "UNAUTHENTICATED" } }

```

Every **other** File Search method accepts the exact same API key in the same session - `files.upload`, `fileSearchStores.create`, `uploadToFileSearchStore`, and `delete` all return 200. Only `importFile` rejects the key.

> **[JavaScript - Gemini API  |  Google AI for Developers](https://ai.google.dev/gemini-api/docs/file-search?authuser=1#javascript_1)**
>
> Check the API reference for importFile for more information. | Get started building RAG solutions with the File Search tool in the Gemini API

---

<div class="post-metadata">

**Author:** ![Duy\_Tien](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/duy_tien/32/129912_2.png) [@Duy\_Tien](https://discuss.ai.google.dev/u/Duy_Tien)\
**Post date:** [June 8, 2026, 3:32pm UTC](https://discuss.ai.google.dev/t/gemini-file-search-importfile-file-id-path-fails-with-401-using-api-key/170022/2 "2026-06-08T15:32:05Z")

</div>

Hi @GoogleGoogle team, can anyone look into this?

seem like it is only working on key with prefix AIz not for AQ

---

<div class="post-metadata">

**Author:** ![Jadranko\_Lucic](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/jadranko_lucic/32/130966_2.png) [@Jadranko\_Lucic](https://discuss.ai.google.dev/u/Jadranko_Lucic)\
**Post date:** [June 12, 2026, 1:30pm UTC](https://discuss.ai.google.dev/t/gemini-file-search-importfile-file-id-path-fails-with-401-using-api-key/170022/3 "2026-06-12T13:30:35Z")

</div>

I also have the same problem. Google, any solution?

---

<div class="post-metadata">

**Author:** ![Duy\_Tien](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/duy_tien/32/129912_2.png) [@Duy\_Tien](https://discuss.ai.google.dev/u/Duy_Tien)\
**Post date:** [June 16, 2026, 3:57pm UTC](https://discuss.ai.google.dev/t/gemini-file-search-importfile-file-id-path-fails-with-401-using-api-key/170022/4 "2026-06-16T15:57:04Z")

</div>

Again, can someone please check?

---

<div class="post-metadata">

**Author:** ![Raul\_Font](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/raul_font/32/131683_2.png) [@Raul\_Font](https://discuss.ai.google.dev/u/Raul_Font)\
**Post date:** [June 17, 2026, 3:52am UTC](https://discuss.ai.google.dev/t/gemini-file-search-importfile-file-id-path-fails-with-401-using-api-key/170022/5 "2026-06-17T03:52:01Z")

</div>

I have the same problem.

---

<div class="post-metadata">

**Author:** ![Radoslav\_Kacharov](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/radoslav_kacharov/32/32374_2.png) [@Radoslav\_Kacharov](https://discuss.ai.google.dev/u/Radoslav_Kacharov)\
**Post date:** [August 7, 2026, 7:22am UTC](https://discuss.ai.google.dev/t/gemini-file-search-importfile-file-id-path-fails-with-401-using-api-key/170022/6 "2026-08-07T07:22:49Z")

</div>

Exactly the same here. It appears it’s still not fixed.  
I would appreciate if someone at-least share some workaround.
