1
votes

Request is successful (status: 200) but no documents are returned.

I populated my firestore collection with 2 sample documents.

I tried to retrieve all documents from firestore collection using the batchGet method at: https://firebase.google.com/docs/firestore/reference/rest/v1beta1/projects.databases.documents/batchGet

This is the POST request URL

https://firestore.googleapis.com/v1beta1/projects/goldcoast-real-estate/databases/(default)/documents:batchGet

I set up the rules so that authentication isn't required. Anyone can read and write

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if true;
    }
  }
}

I am using Google's API explorer to make requests

https://developers.google.com/apis-explorer/#p/firestore/v1beta1/

Including the newTransaction field of the request body returns the transaction id, but still, no documents

{
  "newTransaction": {}
}
1

1 Answers

0
votes

With batchGet, an array of documents to 'get', must be supplied. The format below works for me, although the transaction is readOnly.

POST https://firestore.googleapis.com/v1beta1/projects/foo-bar-12345/databases/(default)/documents:batchGet

{
 "newTransaction": {
 },
 "documents": [
  "projects/foo-bar-12345/databases/(default)/documents/{collectionId}/{documentId}"
 ]
}```