请求同步总是返回 404:“错误:未找到请求的实体". [英] Request Sync always returns 404 : "Error: Requested entity was not found."

查看:34
本文介绍了请求同步总是返回 404:“错误:未找到请求的实体".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难实现 requestSync.它总是返回

I'm having a hard time implementing requestSync. It always returns

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

我使用 Node.js/Express 作为后端.与 Google Home 应用程序的链接/取消链接工作和我的操作也有效.确实是 requestSync 部分失败了.

I use Node.js/Express for the backend. The linking/unlinking with the Google Home app work and my actions work as well. It's really the requestSync part that fails.

我找到的最近的票,虽然不完全一样,是这个吗.

The closest ticket I've found, though not exactly the same, is this one.

我尝试过的东西

  • agentUserId 是一个字符串,但如果我向它传递一个数字,它会返回一个 400,并带有消息'agent_user_id' 处的值无效".

  • agentUserId is a string, but if I pass it a number it returns a 400 with the message "Invalid value at 'agent_user_id'".

尝试发送 agent_user_id 而不是 agentUserId,这返回 404 与发送 agentUserId 时相同的错误

tried sending agent_user_id instead of agentUserId, this returns a 404 the same error as when I send a agentUserId

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

This is what the curl looks like (same as from the example)

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)

(my agentUserId is 1 in this case)

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

And this is what it looks like in code :

    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' },
      },
    );

不管我做什么,结果总是:

Regardless of what I do, the result is always :

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

我不知道还能从哪里找到这个问题.任何指针都会有所帮助.谢谢

I don't know where else to look to identify this problem. Any pointers would help. Thank you

推荐答案

终于找到答案了.

离我的我已经不远了贴在上面.虽然我的问题是我在生成API key的时候,google home云控制台默认打开了错误的项目.我一直使用错误的 API 密钥.

It wasn't too far from the one I had posted above. Although my problem is that when I generated an API key, the google home cloud console opened the wrong project by default. I had the wrong API key all along.

这篇关于请求同步总是返回 404:“错误:未找到请求的实体".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆