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

调用Google Discovery Engine v1alpha API查询数据存储时遇404错误求排查

问题排查方案

1. 修正API请求路径

你的curl请求URL缺少:list后缀,这是Google REST API中list方法的标准调用格式。正确的请求URL应该是:

curl -X GET \
    -H "Authorization: Bearer $(gcloud auth print-access-token --impersonate-service-account=datastore-test@yingruiz-tatc.iam.gserviceaccount.com)" \
    "https://discoveryengine.googleapis.com/v1alpha/projects/yingruiz-tatc/locations/global/dataStores:list"

官方文档中对应的projects.locations.dataStores.list方法,在REST调用时需要在资源路径末尾添加:list来指定具体动作。

2. 确认Discovery Engine API已启用

登录Google Cloud Console,检查项目yingruiz-tatc是否启用了Discovery Engine API:

  • 进入API库,搜索Discovery Engine API
  • 如果未启用,点击"启用"按钮,等待几分钟后再重试请求。

3. 验证服务账号权限

确保服务账号datastore-test@yingruiz-tatc.iam.gserviceaccount.com拥有足够权限列出数据存储:

  • 至少需要Discovery Engine Viewer(roles/discoveryengine.viewer)角色,或者包含discoveryengine.datastores.list权限的自定义角色。
  • 在IAM页面中找到该服务账号,确认已分配对应角色。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.07 08:04:55