
I am using the Python SDK version 9.0.3 (latest) and I am seeing this generic HTTP error pop up.
400 request cannot have request body
The code is dead simple :
from appwrite.client import Client
from appwrite.services.databases import Databases
from appwrite.services.users import Users
from appwrite.exception import AppwriteException
from app.core.config import settings
client = Client()
(client
.set_endpoint(settings.appwrite_endpoint)
.set_project(settings.appwrite_project_id)
.set_key(settings.appwrite_api_key)
)
database = Databases(client)
users = Users(client)
def verify_user_id(user_id: str) -> bool:
try:
users.get(user_id)
return True
except AppwriteException as e:
print(f"Error verifying user ID '{user_id}' : {e.code} {e.response} {e.message}")
return False
Other support requests seem to have the same problem since the release of the Network feature.
Has anyone found a fix for this?

Well the dirty way around is directly using client.call with the proper api path and params. It's pretty annoying but you can copy it from the implementation of the function you are trying to call itself. Also it should only concern GET endpoints

you could write your own functions by copying the SDK implem and simply removing the content-type header

Some more investigation later, it seems like this only occurs when using the new "region" endpoints (for me https://fra.cloud.appwrite.io/v1 ) as when using the basic https://cloud.appwrite.io/v1/ with the 'content-type': 'application/json'
I dont get the 400 request cannot have request body
error. This does seem to be some kind of early routing strategy where the request is thown away if it is both GET and has the application/json
header

@Kenny Could we get someone from their side to confirm this? Seems like a pretty serious issue as it is happening at the REST API level and not at SDK level

I've posted this issue in the channel we have with the core team, so hopefully someone sees it if it isn't already a known issue they're working on.

thank you. Keep me posted if they need anything even though this seems pretty easy to fix

They are looking into the issue and working on a fix.

@lucas 🚀 a workaround that worked for me was to directly call the client.call
method and pass in the params necessary for your case. I was fetching a bucket so this worked client.call("get", path=f"/storage/buckets/{APP_WRITE_BUCKET_ID}")

yep I'm already doing that but I would appreciate seeing it fixed as it is a pretty annoying problem that should not occur in an official sdk

Sounds like a new release has been made that should fix this issue, lmk if it does or doesn't.

hmm, not seeing it officially released yet. I'll update when it is, here is the code change
https://github.com/appwrite/sdk-for-python/commit/54c05a4b657b388a88e52a4e30748ce2b67a6930

it got released in version 10.0.0 of the sdk

so nice to see such fast fix time
Recommended threads
- Wrong number shown on project overview (...
- Collections not showing for relationship...
I am updating one of my databases. I have removed the majority of collection and started adding new collections. The new collections do not appear in the drop d...
- Invalid `userId` param: Parameter must c...
Error: Invalid `userId` param: Parameter must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a speci...
