alan-turing-institute / DTBase

A starting point from which digital twins can be developed.
MIT License
11 stars 4 forks source link

Should we switch all backend API endpoints to use POST only? #210

Open mhauru opened 6 months ago

mhauru commented 6 months ago

In migrating to FastAPI I learned that it's against the HTTP specs to have GET or DELETE endpoints that require a JSON body. (The resource to GET or DELETE should be uniquely identified by the URL.) Since we use JSON bodies for everything and eschew URL parameters, this meant that we had to change almost all of our endpoints to use POST. A few GET endpoints remain, but I wonder if they should be switched to POST just for consistency. For instance, /sensor/list-sensor-types is GET, because it takes no further parameters, but /sensor/list-sensors is POST, because you need to specify in the body which sensor type you want sensors of. I would imagine that users might find this distinction confusing.