How can firestore nested collections be configured as a data resource? I tried nest property types List of Object to access the Document fields in the sub collection but could not get it to work
Hi, I posted an example configuration here.
Hi @Tommy_Bystrom, the UI doesn’t yet support integrating to subcollections, that’s why my example was using an array structure instead. At this point, you could integrate to a subcollection by creating a REST API direct integration from the Data configurator, using the document ID as a URL placeholder.
Okey, thank you. I know it is possible using REST API but was hoping for a more direct way of solving it. The data can not be rearranged because it is an existing webapplication that has been in use by our customer already 3 years. Am only looking for an easy way to make an android-app for his end-customers, it would add value to the whole solution and his business.
as your question points exactly to what I would like to achieve as well: can you please post e.g. a screenshot how you are solving this now with REST API ?
According to my understanding the steps should be like this:
creation of the API as described here : Use the Cloud Firestore REST API | Firebase
using data configurator as described in the AppGyver tutorial : Primer: Integrations and REST APIs - Composer
using my API accoring to the tutorial; including
my project-ID = black
collection = orange
document-ID = blue
sub-collection = green
but when testing, there is an error (despite the fact, that the data is received)
Do you understand this error?
You need to set Response Key Path = documents in the GET COLLECTION (GET) Config tab
Thank you, @JOHN_WORSHAM
your advice works fine!
Thank you all for the input to this topic. I not yet decided if I will try to make the app using REST API or not I was hoping they would have implemented support for subcollections and also since there does not seam to be support for the firebase realtime updates it seams this is not ready yet for Apps with firebase as a backend.
you helped me already a lot on how to configure the GET COLLECTION for a sub-collection on Firestore and it works just fine
Now I am stumbling about difficulties with the PUT and POST:
Let’s have a look on POST; this is what I received when trying my best:
This is how I have set up the object for the test:
and a look on the configuration:
also tried the configuration with “documents” (as it solved the issue with for GET)
Can you help please? I am lost in what firestore requires to comunicate with AppGyver here…
To create a record use HTTP request flow function. Set HTTP method to either post or PATCH (that one to create document setting your own ID). At body variable type in json format accordingly.
Alan, thank you for the hint; still the ‘HTTP Request flow function’ seems to be more complicated and manual work.
I would realy like to get it working with the AppGyver-Data-Configurator.
Luckily I was able to get most of it going by following the docs (yes, it is worthwile to search these again and again ): Google Firestore REST API integration - Composer
(special thanks tho the author @Eduardo_Jaramillo )
Now I can use GET, POST and DELETE
it does not describe how to get PUT running
For PUT it does not work yet:
For DELETE (and also GET and POST) it works fine:
- What is missing?
- Does anybody understand the error-message “Error: TypeError: Failed to fetch. Does the server allow CORS?status: undefined” ?
- How to set up PUT for a firestore sub-collection correctly?
There is no PUT method in Firestore (see Cloud Firestore API | Google Cloud)
That is strange because Firebase Realtime Database accepts PUT.
now, with the understanding that
- the PUT method does not exist for Firestore and
- therefor of course also the data-configurator can not make use of the PUT method in this case
→ I followed @Alan_Alves advice to use the ‘HTTP request’ flow function. It works fine and isn’t as complicated as I feared before. Thanks a lot, Alan!
Here is a screenshot for PATCH to firestore:
Thank You @stayfoolish This helped a lot.
Should be mentioned to the screenshot above:
- the header can stay empty (=default), if no security rules restrict the access to this section in firebase.
- of course it is advisable to set up security rules (at least to: … allow read, write: if request.auth != null; ) and authorize the PATCH request in the header with:
Authorization → Bearer idToken