Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: post() missing 1 required positional argument: 'path' in FastApi?

Tags:

python

fastapi

Where is mistake in FastApi?

Error is:

@video_router.post('/info')
TypeError: post() missing 1 required positional argument: 'path'

api.py

from fastapi import APIRouter
video_router = APIRouter
@video_router.post('/info')
async def info_set(info: UploadVideo):
    return info

main.py:

from fastapi import FastAPI
from api import video_router
app = FastAPI()
app.include_router(video_router)
like image 320
tarp20 Avatar asked Oct 18 '25 09:10

tarp20


1 Answers

The issue is here.

video_router = APIRouter

video_router must be an instance of APIRouter class not the reference to the class itself. So change it to

video_router = APIRouter()
like image 157
Abdul Niyas P M Avatar answered Oct 20 '25 22:10

Abdul Niyas P M