Standardized Web API techniques
In this section, we’ll learn how to use HTTP verbs and status codes properly, how to avoid large dependent resources, how to create paginations for APIs, how to version an API, using DTOs instead of entities, and the best way to make API calls from .NET.
Using the right HTTP verbs and status codes
So far, we’ve looked at how to use HTTP verbs and how to return status codes. While this may seem like a trivial thing, some systems ignore these standards and use POSTs all the time, regardless of the function.
Swagger provides a great template for documenting APIs and with Visual Studio’s new Endpoints Explorer, Visual Studio brings this fundamental documentation down to the developer’s IDE, making the API easier to read and implement in other projects, showing developers what verbs to use and what status codes are expected.
In our example of a shopping cart API earlier in this chapter, users were going to add products...