I need to update certain Firestore documents within transactions.
firestore.projects.databases.documents.beginTransaction fails when creating a readWrite transaction, but succeeds for a readOnly transaction.
I've ensured that the database is in test mode, with all reads and writes open
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
(this fails)
https://firestore.googleapis.com/v1beta1/projects/foo-bar-12345/databases/(default)/documents
{
"options": {
"readWrite": {}
}
}
error response:
{
"error": {
"code": 403,
"message": "Missing or insufficient permissions.",
"status": "PERMISSION_DENIED"
}
}
(this succeeds) - changing options to readOnly, returns a tranasaction
https://firestore.googleapis.com/v1beta1/projects/foo-bar-12345/databases/(default)/documents
{
"options": {
"readOnly": {}
}
}
Successful response:
{
"transaction": "EcMecxy5IXKoIlkAIx+ixOCJ/NT6gvpbaEwWk/5YkOxVxSeMWpOdG4H2nZGK3Y0Pmcj+lbvk6sAlw68UpFgjd8puTpyS2Vwm2X6mw2SKKKKK9OakXxkGgi+8o4vx70Qd4YQaGg=="
}