diff --git a/nfoguard-web/api/web_routes.py b/nfoguard-web/api/web_routes.py index 6c304a2..4b41b20 100644 --- a/nfoguard-web/api/web_routes.py +++ b/nfoguard-web/api/web_routes.py @@ -1136,8 +1136,8 @@ async def get_populate_status(): def register_web_routes(app, dependencies): """Register all web API routes with FastAPI app""" from fastapi import Request, Response - - # Dashboard and stats endpoints + + # Dashboard and stats endpoints @app.get("/api/dashboard") async def api_dashboard(): return await get_dashboard_stats(dependencies) @@ -1259,8 +1259,14 @@ def register_web_routes(app, dependencies): # Database population endpoints @app.post("/admin/populate-database") - async def api_populate_database(background_tasks: BackgroundTasks, media_type: str = "both"): + async def api_populate_database(request: Request, background_tasks: BackgroundTasks): """Populate database from Radarr/Sonarr""" + try: + data = await request.json() + media_type = data.get("media_type", "both") + except Exception: + # Fallback to query parameter if JSON parsing fails + media_type = request.query_params.get("media_type", "both") return await populate_database(background_tasks, media_type, dependencies) @app.get("/api/populate/status")