I want to read in backend this xlsx file. When I use the swagger I get it, but when I test in frontend I receive an Error 422 - devtools/Network detail'': ( ( loc'':(body file msg'':field required'', type'': value_error missing))).
router = APIRouter()
@router.post('/')
async def upload_file(file: Uploadfile = File(...)):
try:
arquivo = await file.read()
df_cambio = pd.read_excel(arquivo)
cambio_dict = df_cambio.to_dict('index')
print(cambio_dict)
return{"file_name": file.filename}
except Exception as e:
exception_handler(e)
react ->
export defaut function Dropzone() {
const [create, {isLoading}] = usePost();
const handleSubmit = (res) => {
create('cambios', { data:res.file }})
};
if (isLoading) { return <LoadingPageSkeleton />;}
return (
<BasicForm
initialValues={{}}
onSubmit={handleSubmit}
>
<FormInput id="file />
<FormSubmitButton/>
</Basicform>