-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Closed
Labels
Description
今天测试一个删除请求,一直报错 ,我是正在学习使用fastapi的一个新手,怎么也解决不了
class CommentDe(BaseModel):
id: int
owner_id_id: int@router.delete('/comment')
async def delete_comment(request: Request, commentIn: CommentDe):
# Authorize.jwt_required()
# owner_id_id = Authorize.get_jwt_subject()
if owner_id_id == commentIn.owner_id_id:
zz = await database.execute(query=comment.delete().where(
comment.c.id == commentIn.id))
if not zz:
raise HTTPException(400, '删除失败')
await request.app.state.redis.hdel('comment:info', commentIn.id)
return {'msg': '删除成功'}
raise HTTPException(400, '权限不够')为了验证这个请求 我把校验字段删了 返回的结果是这样的
INFO: 127.0.0.1:52900 - "DELETE /redis/comment HTTP/1.1" 422 Unprocessable Entity
| 422 | Error: Unprocessable Entity |
|---|
Response body
{
"detail": [
{
"loc": [
"path",
"id"
],
"msg": "value is not a valid integer",
"type": "type_error.integer"
}
]
}但是我的 put操作确实正常的