Firestore REST API数据库监听

时间:2017-11-09 13:25:37

标签: 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 

回复:

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

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

身体应该如何? 提前致谢。

1 个答案:

答案 0 :(得分:2)

通过REST API无法使用listen方法。可通过RPC API使用。