so im making this program using pyrebase 4, and whenever i use this line of code for uploading data to the database in firebase dbreguser = db.child("Users").child("email_something").set(pushObj)
everything goes well, but if I try to replace “email_something” with a str variable it gives me the next error
`Future exception was never retrieved
future: <Future finished exception=TypeError(“string indices must be integers, not ‘str'”)>
Traceback (most recent call last):
File “C:UserssamueDocumentsGitHubMOVTARJETAS.venvLibsite-packagespyrebasepyrebase.py”, line 544, in raise_detailed_error
request_object.raise_for_status()
File “C:UserssamueDocumentsGitHubMOVTARJETAS.venvLibsite-packagesrequestsmodels.py”, line 1024, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://mov-tarjetas-test-default-rtdb.firebaseio.com/Users/[email protected]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “C:UserssamueDocumentsGitHubMOVTARJETASviewsregister.py”, line 87, in register
dbreguser = db.child(“Users”).child(email_string).set(pushObj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:UserssamueDocumentsGitHubMOVTARJETAS.venvLibsite-packagespyrebasepyrebase.py”, line 331, in set
raise_detailed_error(request_object)
File “C:UserssamueDocumentsGitHubMOVTARJETAS.venvLibsite-packagespyrebasepyrebase.py”, line 548, in raise_detailed_error
raise HTTPError(e, request_object.text)
requests.exceptions.HTTPError: [Errno 400 Client Error: Bad Request for url: https://mov-tarjetas-test-default-rtdb.firebaseio.com/Users/[email protected]] {
“error” : “Invalid path: Invalid token in path”
}
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.12_3.12.1008.0_x64__qbz5n2kfra8p0Libconcurrentfuturesthread.py”, line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:UserssamueDocumentsGitHubMOVTARJETAS.venvLibsite-packagesflet_corepage.py”, line 528, in wrapper
handler(*args)
File “C:UserssamueDocumentsGitHubMOVTARJETASviewsregister.py”, line 137, in
ft.ElevatedButton(“Registrarse”, on_click = lambda _: register(page=page, email=correo.value, user=usuario.value, pword=contraseña.value, confpword=conf_contraseña.value))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:UserssamueDocumentsGitHubMOVTARJETASviewsregister.py”, line 94, in register
error = json.loads(error_json)[‘error’][‘message’]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
TypeError: string indices must be integers, not ‘str’`
I dont know what’s the difference between a quoted string and a str var
I have tried sending the email as a string to my function, converting the email into a string inside the function, asingning the string into a varibale and converting it into a string inside that variable then sending the variable to the .child like this
email_string = str(email)
dbreguser = db.child("Users").child(email_string).set(pushObj)
user24594552 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.