1
votes

Below is my Code in raspberry PI's python(Thonny Idle).

Kindly Ignore the Url, it is not the real address. Code

from firebase import firebase

firebase = firebase.FirebaseApplication('https://testing123123-iot.firebaseio.com',authentication=None)

data = {
    'Name':'Hi',
    'Email':'hihi.com',
    'Phone':512232131
        }

result = firebase.post('/testing123123-iot:/Customer', data)
print(result)

Error

Traceback (most recent call last):

File "/home/pi/Documents/PythonCode/TestingFirebase-1.py", line 17, in

result = firebase.post('/testing-iot:/Customer', data)

File "/usr/local/lib/python3.7/dist-packages/firebase/decorators.py", line 19, in wrapped

return f(*args, **kwargs)

File "/usr/local/lib/python3.7/dist-packages/firebase/firebase.py", line 329, in post

connection=connection)

File "/usr/local/lib/python3.7/dist-packages/firebase/decorators.py", line 19, in wrapped

return f(*args, **kwargs)

File "/usr/local/lib/python3.7/dist-packages/firebase/firebase.py", line 97, in make_post_request

timeout=timeout)

File "/usr/local/lib/python3.7/dist-packages/requests/sessions.py", line 340, in post

return self.request('POST', url, data=data, **kwargs)

File "/usr/local/lib/python3.7/dist-packages/requests/sessions.py", line 279, in request

resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)

File "/usr/local/lib/python3.7/dist-packages/requests/sessions.py", line 374, in send

r = adapter.send(request, **kwargs)

File "/usr/local/lib/python3.7/dist-packages/requests/adapters.py", line 174, in send

timeout=timeout

File "/usr/local/lib/python3.7/dist-packages/requests/packages/urllib3/connectionpool.py", line 417, in urlopen

conn = self._get_conn(timeout=pool_timeout)

File "/usr/local/lib/python3.7/dist-packages/requests/packages/urllib3/connectionpool.py", line 232, in _get_conn

return conn or self._new_conn()

File "/usr/local/lib/python3.7/dist-packages/requests/packages/urllib3/connectionpool.py", line 547, in _new_conn

strict=self.strict)

TypeError: init() got an unexpected keyword argument 'strict'

1
Can you fix the formatting of the error message? Why are there <br> tags in there?AMC
This may be a dumb question - are you using any kind of IDE?.. I was having this exact problem while using Spyder3 in Windows 10. I tried my exact same code from cmd and was able to interact with firebase.Branden Keck

1 Answers

0
votes

use json.dumps :

import json

data = {
    'Name':'Hi',
    'Email':'hihi.com',
    'Phone':512232131
    }

sent = json.dumps(data)

result = firebase.post('/testing123123-iot:/Customer', sent)
print(result)