I have an API endpoint at /devices/{id}
. When I call the API without an id
, I get 404 errors with the vague message "Not found"
in the body.
Is there any way to customize the content / message of the 404 error in FastAPI when a parameter (in my case id
) is not found/missing in the called URL?
@app.get("/devices/{id}")
async def get_cellular_data_for_device_id(request: fastapi.Request, id: str):
print("doing something")
404 Error content:
{
"detail": "Not Found"
}