I am new to API development. Using fastapi to create one. I would like to create post request which accepts following JSON and multiple image files.
{ "data": {
"cId": "6351ata0b3ab4640fe595433ed6",
"datain": {
"diameter": 50,
"tolerance": 20
} } }
However I get:
422 Unprocessable Entity.
How should I do it?
I tried to do as following:
class Det(BaseModel):
diameter: int
tolerance: int
class CalData(BaseModel):
cId: str
datain: Det
@app.post("/api/process_image")
async def process_image(
caldata: CalData = Body(...),
files: list[UploadFile] = File(...),
):