Код: Выделить всё
import requests
files = {'template': open('template.xlsx', 'rb')}
payload = {
'context': {
'OUT': 'csv',
'SHORT': 'short'
},
'filename': 'file.xlsx',
'content_type': 'application/excel'
}
r = requests.post('http://localhost:8000/render', files=files, data=payload)
Код: Выделить всё
from fastapi import FastAPI, UploadFile, Form
from pydantic import Json
app = FastAPI()
@app.post('/render')
def render(template: UploadFile, context: Json = Form(), filename: str = Form(...), content_type: str = Form(...)):
# processing
return "ok"
Код: Выделить всё
422Код: Выделить всё
{"detail":[{"loc":["body","context"],"msg":"Invalid JSON","type":"value_error.json"}]}
Как исправить ошибку? Может быть, преобразовать некоторые из них до того, как параметры перейдут в поле зрения, или что-то в этом роде?
Подробнее здесь: https://stackoverflow.com/questions/732 ... rt-request
Мобильная версия