The following is a way to Post data to Firestore
Use Http Request from Flow Function Market and set properties below
URL
“https://firestore.googleapis.com/v1/projects/[PROJECT_ID]/databases/(default)/documents/[COLLECTION_NAME]?documentId=)”+[YOUR_VARIABLE]
Replace everything in brackets with relevant information and remove brackets as well. Sample URL will be like :
“https://firestore.googleapis.com/v1/projects/MyappgyverProject/databases/(default)/documents/Users?documentId=”+appVars.uid
HTTP METHOD Post
expand Optional Inputs
Headers leave as it is or change if you know what you should do
Request Body watch this videos Tutorial ( Appgyver / Firebase CRUD - 1 Setup Firebase - YouTube) 1 to 4 ,it will show you how to create or get a json body. sample body will be like :
{
“fields”: {
"firstname": {"stringValue": "hello"} ,
"lastname": {"stringValue": "world"}
}
}
You can add more fields to the above body to get what you need.
Some of the Field data types to use : “stringValue” ,“integerValue”,“imageurl” .
Request Body Type leave as it is or change if you know what you should do
________________________________________________________
The following is a way to Patch data to Firestore
Patching is a more better way to send data or Post it, it allows you to update records or create new ones if a record with the same ID doesn’t exist. it allows you to create a new or replace the existing one. I don’t understand it well, but I’ve managed to make it work the way i need it to for now.
URL “(https://firestore.googleapis.com/v1/projects/[PROJECT_ID]/databases/(default)/documents/[COLLECTION_NAME]/)”+[YOUR_VARIABLE]
Replace everything in brackets with relevant information and remove brackets as well. Sample URL will be like :
HTTP METHOD Patch
expand Optional Inputs
Headers: leave as it is or change if you know what you should do
Request Body sample body will be like :
{
“fields”: {
"firstname": {"stringValue": "hello"} ,
"lastname": {"stringValue": "world"}
}
}
Request Body Type leave as it is or change if you know what you should do