You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何查找Cloud Firestore项目的数据库ID?使用REST API时找不到项目ID怎么办?

Hey there, let's break this down step by step—finding your Cloud Firestore database ID and sorting out that REST API project ID confusion is totally doable!

How to Find Your Cloud Firestore Database ID

There are a few straightforward ways to track this down:

Via the Google Cloud Console

  • Open the Google Cloud Console and select your target project from the dropdown at the top left.
  • Navigate to the Firestore Database page (you can find this under the "Firebase" section or by searching for "Firestore" in the top search bar).
  • Once you’re in the Firestore dashboard, look at the top of the page or the left sidebar—you’ll see something like your-project-id or your-project-id.firestore.googleapis.com. For native mode databases with a specific region, it might show your-project-id (us-central1).
    • The full database ID follows this format: projects/your-project-id/databases/(default) for the default database. If you’ve created multiple databases, it’ll be projects/your-project-id/databases/your-custom-db-name.

Via the gcloud CLI

If you prefer using the command line:

  • Make sure you have the gcloud CLI installed and authenticated to your project (gcloud auth login if you haven’t already).
  • Run this command:
    gcloud firestore databases list
    
  • The output will show each database’s full resource path (e.g., projects/your-project-id/databases/(default)). Extract the project ID and database name from this path as needed.
Fixing "Can't Find Project ID" Issues with Cloud Firestore REST API

If you’re hitting this error when using the REST API, here are the most common fixes:

1. Verify you’re using the correct project ID (not just the project name)

Project names can have spaces or capital letters, but the project ID is always lowercase, with hyphens instead of spaces, and is unique across Google Cloud. To confirm:

  • Go to your project’s Settings page (click the project dropdown at the top left of the Cloud Console, then select "Project settings").
  • Look for the "Project ID" field—this is the value you need to plug into your REST API endpoints.

2. Check your request endpoint syntax

The Firestore REST API endpoint follows this structure:

https://firestore.googleapis.com/v1/projects/[PROJECT-ID]/databases/[DATABASE-ID]/documents/[COLLECTION-PATH]
  • For the default database, [DATABASE-ID] must be (default) (don’t omit this or replace it with something else).
  • Double-check for typos in the project ID—even a missing hyphen or wrong letter will throw an error.

3. Rule out authentication problems

Sometimes a "can’t find project ID" error is a red herring for an authentication issue:

  • Ensure your API key or service account key is linked to the correct project.
  • If using a service account, make sure it has the necessary Firestore permissions (like Cloud Datastore User or Cloud Datastore Owner roles).
  • Test with a temporary access token to eliminate key issues: run gcloud auth print-access-token in your terminal, then add this header to your request:
    Authorization: Bearer YOUR_GENERATED_TOKEN
    

4. Confirm your Firestore database is initialized

If you’ve created a Google Cloud project but haven’t set up Firestore yet, the API won’t recognize the project as having a Firestore database. Head back to the Firestore Console and complete the initial setup (choose native or Datastore mode, select a region) if you haven’t already.

内容的提问来源于stack exchange,提问作者Alex Mason

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 03:20:34