Designing Queries in HTTP APIs: Using GET, POST and QUERY

Опубликовано: 06 Июль 2022
на канале: Erik Wilde
907
29

Many APIs have some sort of query (or search) capability, where clients send requests to query or search, and then expect results. In simple cases, these capabilities will use the GET request method for HTTP API designs.

However, HTTP GET does not allow request bodies. All query parameters are encoded in the request URI, meaning that there are limitations to what GET requests for query operations can accommodate. As a workaround, many HTTP APIs use POST requests for query operations that for whatever reason have to carry a request body. This works, but has the disadvantage that POST is neither safe nor idempotent, meaning that the HTTP semantics are not aligned with the usually intended request semantics of a query request.

A recent draft by the IETF HTTP working group proposes a new HTTP request method, the QUERY method. This method does allow request bodies, is safe and idempotent, and therefore is a better fit for queries than POST. In this discussion with API expert Mike Amundsen, we discuss how GET, POST, and QUERY compare, and why at least long-term it could be better to use QUERY instead of POST.


IETF Draft "The HTTP QUERY Method": https://datatracker.ietf.org/doc/draf...


Смотрите видео Designing Queries in HTTP APIs: Using GET, POST and QUERY онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Erik Wilde 06 Июль 2022, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 90 раз и оно понравилось 2 людям.