Reputation:
I am trying to update a Firestore document field I have set earlier through REST API.
I have a document (users) which contains all user data. Now I like to be able to update the field 'testfield' - which is part of this user data - through REST API.
I have sent a HTTP POST Request to
https://firestore.googleapis.com/v1/projects/[MY_PROJECT_ID]/databases/(default)/documents/users?documentId=-example
with request body
{
"fields": {
"testfield": {
"booleanValue": true
}
}
}
All I get by now is an error message telling me that the document already exists, what I know, since I am trying to update this document.
Upvotes: 0
Views: 285
Reputation: 317497
According to the Firestore REST API documentation, you use a PATCH request to update a field.
A POST isn't going to work, since that's used for creating new documents. That explains the error that the document already exists.
Upvotes: 1