I am using the Firebase REST API. I would like to check to see if a key exists in my database before writing to it. If it does not exist, I want to create it and write a set of default data to that key. If it does exist, I want to update the data at that key.
Right now I am attempting this by sending a GET request for that key, as in this example:
The REST API will return a
200 status code and a body of
null when the location is empty. Other errors will return a
5xx status code.
curl -I https://example.firebaseio.com/does/not/exist.json HTTP1/1 200 OK ...