1.3: API Project Creation
Last updated
Last updated
Enter the following command in your command line (assuming you are in your project directory):
This scaffolds out a basic API project in your folder.
Let's see what files it created. Open up the folder in VS Code by using this command:
When you open VS Code, you may get a message: Required assets to build and debug are missing from 'EFConnect.API'. Add them?
Select Yes
."
This adds a .vscode folder with low-level configurations that we won't be working with, but will aid our development behind the scenes.
Run the application in the command line:
This will start the application running on port 5000.
Once it is running, open Postman and perform a GET request to http://localhost:5000/api/values.
You should get a 200 Status Code and a response of an array of two strings: "value1" and "value2."
Nice! Everything is hopefully working.
Stop the server with ctrl + c
.
Try starting the server using a slightly different command: dotnet watch run
This will restart the server when you make changes to your application. Helpful for not switching back and forth between the terminal!