Skip to content
Advertisement

Python and FastAPI: keep getting 405 when posting response

I have made at fasstapi at https://lectio-fastapi.herokuapp.com/docs#/

JavaScript

When I test on the fastapi site it works like a charm.

But when I try to access it from another python program i get 405 when posting

JavaScript

the output I am getting is:

JavaScript

And I am expecting to get these returns:

JavaScript

It seems like to me I need to define something more in FastAPI to get my post function to work. But not sure what is missing.

Advertisement

Answer

First, you need to change request in the lectio_root

JavaScript

to

JavaScript

because, in your app, read_root function have GET request, not POST.

Second, you need to change send_msg decorator

JavaScript

to

JavaScript

because, inside lectio_send_msg function you are sending POST request.

Advertisement