Firebase UPDATE RECORD (PUT) error 404

Hi,

I’m working on a appgyver project with firebase as a bakend database.

I did some test to be sure all the feature works as expected

So I connect my data to Firebase and tested successfully the command:

GET COLLECTION (GET)
GET RECORD (GET)
CREATE RECORD (POST)

but I have a problem with

UPDATE RECORD (PUT)

I set up the same schema in both the CREATE and the UPDATE

When I test the UPDATE RECORD (PUT) command, I receive back this message:

Error: Non-JSON error body.status: 404

Resource settings for Update record (PUT)
-------------------
Resource URL: https://firestore.googleapis.com/v1beta1/
Relative path: projects/MYPROJECT/databases/(default)/documents/Ricette/{id}/{collection}/

Looking on the browser console, the error message is:

Failed to load resource: the server responded with a status of 404 ()

and the link address is

https://firestore.googleapis.com/v1beta1/projects/MYPROJECT/databases/(default)/documents/Ricette/ricette5/ingredienti01/

If I try to access the link directly from the WEB browser I receive back the data schema

{
  "documents": [
    {
      "name": "projects/MYPROJECT/databases/(default)/documents/Ricette/ricette5/ingredienti01/HAlJ0tVnFy84gQwnfzbW",
      "fields": {
        "ing01_units": {
          "stringValue": ""
        },
        "ing01_name": {
          "stringValue": ""
        },
        "ing02_number": {
          "stringValue": ""
        },
        "ing02_units": {
          "stringValue": ""
        },
        "ing01_number": {
          "stringValue": ""
        },
        "ing02_name": {
          "stringValue": ""
        }
      },
      "createTime": "2022-09-21T17:04:26.669312Z",
      "updateTime": "2022-09-21T17:04:26.669312Z"
    }
  ]
}

so it seems the resource is accessible.

If I use the GET RECORD with the same parameter, I receive back the same schema.

On Firebase I set the rules to accept read and write

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

Any suggestion on how to solve this issue?

Thank you
Giovanni

It seems that the problem is that Firebase Firestore does not accept the PUT command as stated in the documentaion.

It supports PATCH instead but this is not added in the DATA method.

So it seems that there are two options to change a value in a Firestore document:

1 - do not use the DATA command directly but implement a HTTP request with PATCH and parameters according to the manual

2- Use GET, store data locally, delete the document using DELETE and then recreate the record using POST

It should be nice instead to have the PUSH command as a native command for the Firestore database or at list indicate near the PUT command that the command does not work with Firestore database