在多部分表单数据中发送多个参数

时间:2021-02-24 12:50:16

标签: python http post

我正在尝试发送一个以图像和标题为键的表单数据请求。到目前为止,我只能发送图像。

这是带有图像的 POST 请求。

enter image description here

这是我尝试添加标题参数时的 POST 请求。

enter image description here

处理这个请求的python代码如下:

@router.post('/{id}/upload_image', status_code=HTTP_201_CREATED)
def upload_client_image(
    title: str,
    image: bytes = File(...),
    id: int = Path(..., ge=0),
):
   #do something with info
   return HTTP_201_CREATED

如果我删除 title: str 行,请求工作正常。我也试过它作为 title: str = Field(...) 但我一直收到“AttributeError:'FieldInfo'对象没有属性'in_'”的错误。我做错了什么?

0 个答案:

没有答案
相关问题