Request Sync always returns 404 : "Error: Requested entity was not found."

Request Sync always returns 404 : "Error: Requested entity was not found."

我很难实现 requestSync。它总是 returns

  "error": {
    "code": 404,
    "message": "Requested entity was not found.",
    "status": "NOT_FOUND"
  }

我使用 Node.js/Express 作为后端。 linking/unlinking 和 Google Home 应用程序可以正常工作,我的操作也可以。确实是 requestSync 部分失败了。

我找到的最近的票,虽然不完全一样,is this one

我尝试过的事情

这是卷曲的样子(与示例相同)

curl -i -s -X POST -H "Content-Type: application/json" -d "{agent_us
er_id: \"1\"}" "https://homegraph.googleapis.com/v1/devices:requestSyn
c?key=API_KEY"

(本例中我的 agentUserId 为 1)

这就是它在代码中的样子:

    const res = await fetch(
      `https://homegraph.googleapis.com/v1/devices:requestSync?key=${config.googleApiKey}`,
      {
        method: 'POST',
        body: JSON.stringify({
          agentUserId: String(userId),
          async: true,
        }),
        headers: { 'Content-Type': 'application/json' },
      },
    );

无论我做什么,结果总是:

  "error": {
    "code": 404,
    "message": "Requested entity was not found.",
    "status": "NOT_FOUND"
  }

我不知道还有什么地方可以确定这个问题。任何指针都会有所帮助。谢谢

终于找到答案了。

the one I had posted above不远。虽然我的问题是当我生成了一个API键的时候,google家云控制台默认打开了错误的项目。我一直有错误的 API 密钥。