Back
KeyError: 'content-type' when calling delete_document() function in Python
- 0
- Self Hosted
- Databases
lukaskruedel
Hi everybody, I have encountered and error and wanted to see if anybody else encountered the same before opening an Issue.
For context, I have the following code:
TypeScript
client = Client()
client.set_endpoint('<Project_Endpoint>')
client.set_project('<Project_ID>')
client.set_key('<KEY>')
db = Databases(client)
delete_response = db.delete_document(
database_id='<DB_ID>',
collection_id='<COLLECTION_ID>',
document_id='<Some_ID>'
)
Output:
TypeScript
Traceback (most recent call last):
File "C:\Users\some_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\appwrite\client.py", line 121, in call
content_type = response.headers['Content-Type']
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
File "C:\Users\some_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\structures.py", line 52, in __getitem__
return self._store[key.lower()][1]
~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'content-type'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\some_user\Downloads\appwrite_delete.py", line 15, in <module>
delete_response = db.delete_document(
^^^^^^^^^^^^^^^^^^^
File "C:\Users\some_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\appwrite\services\databases.py", line 1031, in delete_document
return self.client.call('delete', api_path, {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\some_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\appwrite\client.py", line 132, in call
content_type = response.headers['Content-Type']
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
File "C:\Users\some_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\structures.py", line 52, in __getitem__
return self._store[key.lower()][1]
~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'content-type'
TL;DR
Developers encountered KeyError 'content-type' when calling delete_document() function in Python due to a missing header key. To solve this, developers should modify the content-type key in the response headers to 'Content-Type'. Recommended threads
- `notContains` Query not available
I have a collection with documents that have a `userIds` attribute containing an array of string values. I want to list these documents by excluding the ones th...
- Cant use dotnet-8.0 and Deno 2.0 Runtime...
Hi, i cant get up and running any .net and deno 2.0 runtimes. Steps i tried: 1. Added in .env: _APP_FUNCTIONS_RUNTIMES=deno-2.0,php-8.3,python-3.9,dotnet-8.0 2....
- can’t log in after launching to the inte...
I built a database for a client, and though i’m a novice, the process wasn’t so bad. It worked great with localhost. When i put it on the web, i changed the A...