Let's say I have a registration page with a user where they create a new account. If the user is already registered by that email, I'll return a 409 CONFLICT
status. However, I'm not quite sure what the proper content is required to return with that -- for example, do I return that user object? Do I return nothing? Do I return a text message? Here is what I have thus far:
@app.post("/users", status_code=status.HTTP_201_CREATED)
def create_user(user: schemas.UserCreate, db: Session = Depends(get_db)):
# ... some logic
try:
db.commit()
except sqlalchemy.exc.IntegrityError:
return Response(status_code=status.HTTP_409_CONFLICT)
# ...
Are there any reference APIs that show what is supposed to be returned with a 409
?