Google Cloud Platform - Firestore vs Firebase Webhook Integration

Hi,

I’ve been going through @rickkas7’s tutorials for Google Cloud Platform Integration - https://github.com/rickkas7/firebase_tutorial and noticed that the tutorial is for Google Firebase which is the “legacy” realtime database integration. The newer version of the database is Google Firestore which offers some great improvements over Firebase.

When I ran Rick’s test1data example using the a webhook url such as:
https://myproject.firebaseio.com/test1data/data.json GCP automatically created a legacy Firebase database to store the data in, despite me not having created it previously.

Firestore uses a different URL structure which i adapted into my webhook -https://firestore.googleapis.com/v1/projects/myproject/databases/(default)/documents/test2data/data.json

I deleted the previous webhook from Particle and updated with the new webhook file and url structure, however when I publish an event I get a 400 error in the console logs:

My full webhook file looks like this:

{
    "event": "test2data",
    "url": "https://firestore.googleapis.com/v1/projects/myproject/databases/(default)/documents/test2data/data.json",
    "requestType": "POST",
    "query": {
    	"auth":"--- auth token goes here----"
    },
    "json": {
		"a": "{{a}}",
		"b": "{{b}}",
		"c": "{{c}}",
		"ts": "{{PARTICLE_PUBLISHED_AT}}"
    },
    "mydevices": true,
    "noDefaults": true
}

Has anyone successfully been able to get a simple webhook to pass data to Google Firestore? (not Firebase). I have contemplated taking the approach outlined in this tutorial - https://docs.particle.io/tutorials/integrations/google-cloud-platform/ which has some security advantages, but requires a cloud script/function to save the data to Firestore (or other DB).

@rickkas7, would it be possible for you to put together a Firestore tutorial similar to your Firebase one?

Thanks!

Nolan

1 Like