Firestore REST API database listening

2020-07-16 03:23发布

问题:

Do you know how to setup Firestore listening using REST API. This is my attempt:

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 

And the response:

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

Most propably, my request body is invalid. I used this reference: https://firebase.google.com/docs/reference/rest/firestore/v1beta1/projects.databases/listen

How is the body should look like? Thanks in advance.

回答1:

The listen method is not available through the REST API. It is available through the RPC API.