Code: Select all
var formData = new FormData();
export_param = {"data":"test"} // json data
formData.append('metadata',JSON.stringify(export_param));
var dataurl = imagePreviewRef.current.makeImageDataUrl();
var blobData = createBlob(dataurl);
formData.append("file",blobData);
axios.post(qs_url,formData,{headers: {'Content-Type': 'application/form-data'}}).then(res=>{
dann möchte ich Erhalten Sie dies in FastAPI
Code: Select all
@app.exception_handler(RequestValidationError)
async def validation_exception_handler(request: Request, exc: RequestValidationError):
exc_str = f'{exc}'.replace('\n', ' ').replace(' ', ' ')
logging.error(request, exc_str)
content = {'status_code': 10422, 'message': exc_str, 'data': None}
return JSONResponse(content=content, status_code=status.HTTP_422_UNPROCESSABLE_ENTITY)
@app.post('/plan/myslace')
async def getcreatePlan(file: Annotated[bytes, File(default=None)],metadata:Annotated[str,Form(default="test")]):
print(test_param)
return {"myslace":"OK"}
Code: Select all
fastapi.exceptions.RequestValidationError: 2 validation errors for Request
query -> file
field required (type=value_error.missing)
query -> metadata
field required (type=value_error.missing)
Wo soll ich das beheben?