Skip to content
Init is coming / May 19 - 23
Back

Python SDK: users.get(user_id) error : 400 request cannot have request body

  • 1
  • Auth
  • Cloud
lucas 🚀
17 Apr, 2025, 12:57

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 :

TypeScript
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?

TL;DR
Developers using Python SDK version 9.0.3 are encountering a '400 request cannot have request body' error when using the `users.get(user_id)` function. This error seems to be linked to the Network feature update. A potential fix for this issue has not been identified at this time.
lucas 🚀
17 Apr, 2025, 13:35

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

lucas 🚀
17 Apr, 2025, 13:36

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

lucas 🚀
17 Apr, 2025, 13:45

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

lucas 🚀
17 Apr, 2025, 13:47

@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

Kenny
17 Apr, 2025, 13:50

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.

lucas 🚀
17 Apr, 2025, 13:50

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

Kenny
17 Apr, 2025, 17:45

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

rc_william
17 Apr, 2025, 18:08

@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}")

lucas 🚀
17 Apr, 2025, 19:29

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

Kenny
17 Apr, 2025, 21:02

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

Kenny
17 Apr, 2025, 21:04

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

lucas 🚀
18 Apr, 2025, 19:45

it got released in version 10.0.0 of the sdk

lucas 🚀
18 Apr, 2025, 19:46

so nice to see such fast fix time

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more