FastAPI Application, I want to make a POST Request with files (UploadFile), a body that contains the user_info, user_id as well as anything else. Would this be possible?
Asked
Active
Viewed 526 times
0
-
Welcome to SO! Please [Take the Tour](https://stackoverflow.com/tour), read: [What types of questions should I avoid asking?](https://stackoverflow.com/help/dont-ask), [What topics can I ask about here?](https://stackoverflow.com/help/on-topic) and [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example). Yes, this is possible. What have you tried? Give us a specific problem and we can help. – Michael Ruth Oct 03 '22 at 20:03
-
Yes, I tried, I manage to make it work with a query param and a form-data (for the files), but I was wondering if it would be possible with a JSON body instead since it's a post request. – STY Oct 03 '22 at 20:35
-
You have to use `Form()` data in that case, since that's what an UploadFile is. Mixing JSON bodies and form-data-bodies isn't possible. – MatsLindh Oct 03 '22 at 21:35