Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14011

How to send data and a file from one fastapi to another one? [duplicate]

$
0
0

I am executing the following post:

response = requests.post(url=f'{os.environ["BASE_URL"]}/submit',                                 files={'file': (file.filename, file.file)},                                 data = {'query': 'John Doe','model': '90.5'})

and in the other side I have the following endpoint:

class SubmitRequest(BaseModel):    query: str    model: str@app.post("/submit")async def submit(   query: str = Form(...),   model: str = Form(...),   files: UploadFile = File(...)):   log.info("hello")

It retrieves a 422 Entity error, what am I doing wrong? Thank you


Viewing all articles
Browse latest Browse all 14011

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>