確認錯誤訊息中顯示的專案 ID 對應於您打算部署 Endpoints 設定的 Google Cloud 專案:
gcloud projects list
確認 gcloud CLI 的專案 ID 已設為目前的專案,而且正確無誤:
gcloud config set project YOUR_PROJECT_ID
呼叫端沒有權限
ERROR: (gcloud.endpoints.services.deploy) PERMISSION_DENIED: Caller does not have permission 'servicemanagement.services.create' on
project YOUR_PROJECT_ID
第一次部署 Endpoints 設定時,Service Management 會為您的 API 建立代管服務。如要建立代管服務,您必須至少在專案層級擁有編輯者角色。在 Service Management 建立代管服務之後,重新部署 Endpoints 設定的最低必要權限是擁有服務的服務設定編輯者角色 (roles/servicemanagement.configEditor)。詳情請參閱「授予 API 的存取權」。
無法驗證網域名稱的擁有權
ERROR: (gcloud.endpoints.services.deploy) PERMISSION_DENIED: Ownership for domain name YOUR_DOMAIN_NAME on project
YOUR_PROJECT_ID cannot be verified
如果您在 api_config.yaml 檔案的 name 欄位中設定了自訂網域 (例如 example.com),則必須先驗證網域名稱才能部署服務設定。
如果您使用 cloud.goog 網域,請確認 name 欄位的值採用下列格式,且專案 ID 正確無誤:
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[[["\u003cp\u003eThis page provides guidance on troubleshooting common errors encountered when deploying Cloud Endpoints configurations, specifically with gRPC.\u003c/p\u003e\n"],["\u003cp\u003eMismatched fields between protocol buffer messages and transcoding mappings in your \u003ccode\u003e.proto\u003c/code\u003e file can lead to a "Cannot convert to service config" error.\u003c/p\u003e\n"],["\u003cp\u003ePermission errors such as "Not allowed to get project settings" or "Caller does not have permission" may be resolved by re-authenticating with \u003ccode\u003egcloud\u003c/code\u003e, verifying the correct project ID is selected, and ensuring appropriate roles are granted.\u003c/p\u003e\n"],["\u003cp\u003eIf using a custom domain, "Ownership for domain name cannot be verified" errors require domain verification, and if utilizing the \u003ccode\u003ecloud.goog\u003c/code\u003e domain, confirm the correct formatting and project ID within your \u003ccode\u003eapi_config.yaml\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eFor any unlisted errors, running the \u003ccode\u003egcloud\u003c/code\u003e command with the \u003ccode\u003e--verbosity=debug\u003c/code\u003e flag will display debug information to aid in resolving the problem.\u003c/p\u003e\n"]]],[],null,["# Troubleshooting Cloud Endpoints configuration deployment\n\n[OpenAPI](/endpoints/docs/openapi/troubleshoot-config-deployment \"View this page for the Cloud Endpoints OpenAPI docs\") \\| gRPC\n\n\u003cbr /\u003e\n\nThis page describes how to troubleshoot errors that you might encounter when you\ndeploy your Cloud Endpoints configuration. The error messages that you see\ncontain information specific to your project. For example, you might see an\nerror message that has your project ID in it. On this page you'll see\nplaceholder values such as \u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e.\n\nAfter each step, run the `gcloud endpoints services deploy` command again to see\nif the error is resolved.\n\nCannot convert to service config\n--------------------------------\n\n`ERROR: (gcloud.endpoints.services.deploy) INVALID_ARGUMENT:` \n\n`Cannot convert to service config. http: undefined field \u003cunknown\u003e\non message \u003cRequestType\u003e`\n\nCheck your `.proto` file for mismatched fields between your\nprotocol buffer messages and [transcoding mappings](/endpoints/docs/grpc/transcoding).\n\nFor example, the following in a `.proto` file produces this\nerror. The mapping option on `Unary` specifies a field named\n`undefined` that isn't in the `Request` message\ndefinition. \n\n```\nrpc Unary(Request) Response {\n option (google.api.http) { get : \"/{undefined}\" };\n}\n\nmessage Request {\n string defined = 1;\n}\n```\n\nNot allowed to get project settings\n-----------------------------------\n\n`ERROR: (gcloud.endpoints.services.deploy) PERMISSION_DENIED:` \n\n`Not allowed to get project settings for project `\u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e`\n`\n\n1. Authenticate with gcloud CLI again to confirm that you authenticated with an account that has permission to access the project displayed in the error message: \n\n ```text\n gcloud auth login\n ```\n\n A new browser tab opens and you are prompted to choose an account.\n2. Confirm that the project ID displayed in the error message corresponds to the Google Cloud project that you intend to deploy the Endpoints configuration to: \n\n ```text\n gcloud projects list\n ```\n3. Confirm that gcloud CLI has the correct project ID set as the current project: \n\n ```scdoc\n gcloud config set project YOUR_PROJECT_ID\n ```\n\nCaller does not have permission\n-------------------------------\n\n`ERROR: (gcloud.endpoints.services.deploy) PERMISSION_DENIED:` \n\n`Caller does not have permission 'servicemanagement.services.create' on\nproject `\u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e\n\nWhen you first deploy the Endpoints configuration,\nService Management creates a managed service for your API. To create a managed\nservice, at a minimum you must have the **Editor** role at the project level.\nAfter Service Management creates the managed service, the minimum required\npermissions to redeploy an Endpoints configuration is the\n**Service Config Editor** role (**roles/servicemanagement.configEditor** )\non the service. For more information, see\n[Granting access to the API](/endpoints/docs/grpc/control-api-access).\n\nOwnership for domain name cannot be verified\n--------------------------------------------\n\n`ERROR: (gcloud.endpoints.services.deploy) PERMISSION_DENIED:` \n\n`Ownership for domain name `\u003cvar translate=\"no\"\u003eYOUR_DOMAIN_NAME\u003c/var\u003e` on project\n`\u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e` cannot be verified`\n\n- If you have a custom domain (for example, `example.com`) configured in the `name` field of your `api_config.yaml` file, you must [verify the\n domain name](/endpoints/docs/grpc/verify-domain-name) before you can deploy the service configuration.\n- If you are using the `cloud.goog` domain, confirm that the value for the `name` field is in the following format, and that the project ID is correct: \n\n ```scdoc\n API_NAME.endpoints.YOUR_PROJECT_ID.cloud.goog\n ```\n\nTroubleshooting other errors\n----------------------------\n\nIf you received an error not listed here, or if the information didn't\nsolve your problem, run the `gcloud` command again with the flag\nto display debug information: \n\n```scdoc\ngcloud --verbosity=debug endpoints services deploy api_descriptor.pb api_config.yaml api_config_http.yaml\n```\n\nWhat's next\n-----------\n\n- [`gcloud endpoints services deploy`](/sdk/gcloud/reference/endpoints/services/deploy)\n- [Overview of API access](/endpoints/docs/grpc/api-access-overview)"]]