''HTTP Error 401: Unauthorized' Unable to use Deta Base
I am using Deta Base to create a API using the Fast API framework. I was able deploy my API using deta micros, it worked like a dream.
However, when I am trying to use the 'Deta Base' feature, It is giving me the following error:
urllib.error.HTTPError: HTTP Error 401: Unauthorized
I have logged in in the terminal already, this was the result.
deta login
Logged in successfully.
I have checked that my project key is correct, I also made a new project and copied and pasted the id directly in, so I am sure that my project key is linked to a Deta project.
This is my code.
# python-decouple
from decouple import config
DETA_PROJECT_KEY = config('DETA-PROJECT-KEY')
DETA_PROJECT_ID = config('DETA-PROJECT-ID')
DETA_BASE_NAME = config('DETA-BASE-NAME')
# Deta Base
from deta import Deta
deta = Deta('DETA-PROJECT-KEY')
locations_of_interest = deta.Base('locations_of_interest')
locations_of_interest.insert({"hello":"world"})
new_home = next(locations_of_interest.fetch({"hello":"world"}))
How can I fix this?
Thank you for your help!!
Solution 1:[1]
Figured that for the http api, put/post should be sent to https://database.deta.sh/v1/{project_id}/{base_name}/items and not just to https://database.deta.sh/v1/{project_id}/{base_name}/
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
