From the course: Learning ASP.NET Core: MVC, Razor Pages, Web APIs & Other Foundations
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Solution: Create a Web API
From the course: Learning ASP.NET Core: MVC, Razor Pages, Web APIs & Other Foundations
Solution: Create a Web API
(upbeat music) - [Instructor] I am going to show you how I solved the challenge, but don't worry if your code doesn't exactly match mine. The goal is to create a working web API and reinforce your understanding of the project types. To get started, I'm going to use the dotnet CLI to create a new minimal API project. The command to do that is dotnet new webAPI. I want to create the project in a new directory named books-API. I'll specify that with the -O option. I'll now switch to that directory and open the project in VS Code. All of the code that comes with the project template is in the program.CS file. I'm going to add all of the code for the challenge in here, but I don't need the sample code specific to serving weather forecast data, so I'll delete the summaries variable, the existing call to map get and the weather forecast record declaration at the end of the file. Since this service will serve book data, I want to book model to use. I could create a class, but a record will be…