1

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 Answer 1

0

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}"
 ]
}```
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.