Updating single fields and other random Firebase REST API tips

Dear amazing people,

I have been using Appgyver for exactly a month today, and while it has been hard for me as a non-tech newbie, I learnt quite a ton. I have collated micro documentation of the major tips I learnt on the way and thought it might be helpful for other Firebase backend users.

Tips currently cut across Authentication, updating documents fields and many more. I highly encourage collaboration to add to this list of tips, and I hope you find these as useful as I did.

Ooh, and if you find another lost copy of this on the forum kindly alert me, I had tried to upload this earlier and had bad internet connection so I don’t know here that went.

Cheers.

REST API

How to Update a document using the PATCH method for REST API.

Use the following URL.

How to Update a single field using the PATCH method for REST API. Reference Resources

Use the following URL.

How to get a document using GET method for REST API

Use the following URL.

How to get a field from a document using Get method for REST API

Use the following URL.

How to get a collection of documents using REST API

Use the following URL.

How to delete a one or more field(s) form a document using PATCH method for REST

Use the following URL. However, in the body of the HTTP request, do not add any update for the field. This does the function of deleting only that field.

How to create one or more new field(s) into a document using PATCH method for REST

Use the following URL. IN the body of the HTTP request, write the field name as key and Value only.

How to create a document using POST method for REST

Use the following URL. In the body of the HTTP request, write the intended field of the document.

How to create a document, with an assigned documentID using POST method for REST

Use the following URL, ensure to add ?documentid={DocumentID}. In the body of the HTTP request, write the intended field of the document.

How to create Subcollection with a Document inside of it using POST method for REST

Use the following URL. In the body of the HTTP request, write the intended field of the document.

How to store a file in Firebase storage and connect it to you database Using POST method on REST API

Use the following URL. In the body of the message, upload a binary file into the image.

How to retrieve a file in Firebase storage and connect it to you database Using GET method on REST API

If there is no authentication rule on the storage, use the following URL.

If there is an authentication rule on the storage, use the following URL.

How to retrieve a file in Firebase storage and connect it to you database Using GET method on REST API

If there is no authentication rule on the storage, use the following URL.

If there is an authentication rule on the storage, use the following URL.

Sample Field Format:

{

“fields”: {

	}

}

How to connect Collection from firestore REST API to Appgyver

  1. Copy the path: https://firestore.googleapis.com/v1beta1/projects/{projectID}/databases/(default)/documents/{CollectionID} from the firestore
  2. Open Appgyver composer platform and open the Data configurator. Add Data Resources and choose REST API intergration.
  3. Paste the https://firestore.googleapis.com/v1beta1/ as the Resources ID for the Base
  4. Go to the GET COLLECTION (GET) and past the projects/{projectID}/databases/(default)/documents/{CollectionID} as the Relative path.
  5. Run Test and Generate Schema.

How to Connect Data from FireStore to Appgyver

  1. Create Data Variable from the generated collection

How to create a record on Appgyver from Firestore

  • Fill in the details of the Create Record(POST) session of the resource

How to signup and verify a new user using email and password with POST method on REST API

Step 1: Sign-up

Use the following URL: https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=[API_KEY]

And create in the request body, {“email”:"[user@example.com]",“password”:"[PASSWORD]",“returnSecureToken”:true}

You will get a response body like this:

{

“idToken”: “[ID_TOKEN]”,

“email”: “[user@example.com]”,

“refreshToken”: “[REFRESH_TOKEN]”,

“expiresIn”: “3600”,

“localId”: “tRcfmLH7…”

}

Step 2: Send verification code:

Use the following URL: [https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=API_KEY]

Create a request payload:

{"requestType":"VERIFY_EMAIL","idToken":"[FIREBASE_ID_TOKEN]"}

How to Create a Search box that autosuggests: Link

9 Likes

Hey,
I am new to Appgyver and I would like to say thanks for posting this, it is nice to have a cheatsheet to help with trying to know what to do.

CAREFULL : not “documentid” but “documenId”

1 Like

I tried creating a documentId with post and it worked great, the only thing is I had to write the new document ID inside the URL. Is there a way that we can have an input value fromfrom an input field on the UI that could change the URL’s documentId?

That should be possible via using a page variable :slight_smile: If you are unsure how to work with variables, check out these videos: Core Lesson 1 - Variables & Formulas - AppGyver

How do we form the update mask to edit a field in a nested array or map or to add a new item to a nested array? I have searched all the firebase docs and can find nothing about it.