I am using python-firebase and can't seem to get data to POST properly. Whatever I send is POSTED to firebase but the entities are not viewable in the dashboard as JSON. Here is my code:
json = '{ url: "' + url + '" address: "' + address + '" name: "' + name + '"}'
result = firebase.post("/businesses", json )
In the Dashboard for a POSTED entity I see:
Any idea on how I can get the entities to POST properly?
Insert record in firebaseImport library of Firebase in Python script. Then, create database connection using the below command. FirebaseApplication takes two parameters; one is URL of database and second is authentication details for database. But we don't have any rules so we are passing None.
We currently support Python 3.7+. Firebase Admin Python SDK is also tested on PyPy and Google App Engine environments.
Your JSON keys need to be strings in quotes. There are also no commas in your JSON string. Neatest way is to use the json
library:
import json
# your variables are already assigned before this
data = {'url': url, 'address': address, 'name': name}
sent = json.dumps(data)
result = firebase.post("/businesses", sent)
Your JSON is not valid (no commas between dict entries) but you can post a normal dict instead of a JSON string anyway:
data = {'url': url,
'address': address,
'name': name}
result = firebase.post("/businesses", data)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With