Firestore REST API数据库监听

Raj*_*jju 5 rest firebase google-cloud-firestore

您知道如何使用REST API设置Firestore侦听。这是我的尝试:

url: "https://firestore.googleapis.com/v1beta1/projects/project_name/databases/(default)/documents:listen"
headers: {["Content-Type"] = "application/json"}

body: "{"addTarget": { 
            "once" : false, 
            "documents" : { 
                    "documents" : [ "projects/project_name/databases/(default)/documents/Users/USER_DOC_ID" ]
                        }
            }}"

Request verb: POST 
Run Code Online (Sandbox Code Playgroud)

以及响应:

  [{
    "error": {
      "code": 400,
      "message": "Invalid value (Object), ",
      "status": "INVALID_ARGUMENT",
      "details": [
        {
          "@type": "type.googleapis.com/google.rpc.BadRequest",
          "fieldViolations": [
            {
              "description": "Invalid value (Object), "
            }
          ]
        }
      ]
    }
  }
  ]
Run Code Online (Sandbox Code Playgroud)

最可能的是,我的请求正文无效。我使用了以下参考:https : //firebase.google.com/docs/reference/rest/firestore/v1beta1/projects.databases/listen

身体看起来如何?提前致谢。

Jua*_*ara 2

侦听方法无法通过 REST API 使用。它可以通过RPC API获得。

  • 您能详细说明一下吗?为什么 REST API 不支持侦听器?RPC 文档也非常模糊。 (3认同)