Introduction: Rest API Endpoints

Get introduced with REST API endpoints.

We'll cover the following


In Understanding the ASP.NET React Template, we learned that a RESTful endpoint is implemented using an API controller in ASP.NET. In this section, we’ll implement an API controller for our Q&A app that will eventually allow the frontend to read and write questions and answers. We’ll implement a range of controller action methods that handle different HTTP request methods returning appropriate responses.

We’ll learn about dependency injection and use this to inject the data repository we created in the previous part into the API controller. We’ll validate requests so that we can be sure the data is valid before it reaches the data repository.

At the end of the chapter, we’ll ensure we aren’t asking for unnecessary information in the API requests. This will prevent potential security issues as well as improve the experience for API consumers.

Get hands-on with 1200+ tech skills courses.