Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why fastapi trace http method not working?

that’s my code idk what should i put in view

TypeError: Failed to execute ‘fetch’ on ‘Window’: ‘TRACE’ HTTP method is unsupported.

from fastapi import FastAPI

app = FastAPI()

@app.trace("/")
def test_trace():
    ...

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

That’s not a problem with your code but the browser. The TRACE HTTP method has little to no support on browsers according to MDN. And since the swagger UI page for FastAPI uses the browser to make these API calls, it may not work.

However your code is working as expected. You can check that by using curl:

(venv) ➜ curl -X TRACE http://127.0.0.1:8000
"test"%                                                                                                                                                                     (venv) ➜ 

From the handler method:

@app.trace("/")
def test_trace():
    return "test"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading