-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Cannot upload an image using API with python #5239
Copy link
Copy link
Closed
Description
Hey, I am working on a project where I need to upload images to pocketbase database. Database schema is like this:
timestamp: DateTime
img: File
processed: Boolean
I am using this approach to upload the image:
with open("img.jpeg", "rb") as file:
encoded_string = base64.b64encode(file.read()).decode("utf-8")
url = "https://pbdev1.s1.ixon.cc/api/collections/hawknest_raw/records"
headers = {
"Content-Type": "application/json",
"Authorization": f"{API_KEY}"
}
data = {
"timestamp": "",
"img": encoded_string,
"processed": False
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response)
It is giving 400 response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels