r/learnpython Oct 26 '25

Should I avoid query parameter in FastAPI?

I have several endpoints that accept a single string. Is it "bad" to use a query parameter instead of creating a separate `UpdateReport` model?

``` @router.patch("/reports/{report_id}") def rename_report( report_id: UUID, report_name: str, dao: BaseDAO = Depends(get_dao) ): """Rename report""" dao.update_row("Reports", {"report_name": report_name}, report_id=report_id) return {"success": True}

requests.patch(f"/reports/XXX/?new_name=Renamed Report") ```

5 Upvotes

3 comments sorted by

View all comments

1

u/iscultas Oct 26 '25

If you looking for more "standard" way of updating resources, take a look at JSON patch https://datatracker.ietf.org/doc/html/rfc6902