From the course: Building Angular and ASP.NET Web API Apps

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Creating a Web API HttpPost endpoint

Creating a Web API HttpPost endpoint

From the course: Building Angular and ASP.NET Web API Apps

Start my 1-month free trial

Creating a Web API HttpPost endpoint

- [Instructor] To create a new entry, either an expense or an income, we are going to create an API endpoint which is going to handle these kind of requests. So, for example, when the user posts or sends some data to the back-end, our API endpoint is going to check for data and then save it in our database. So, let's get started. In your visual studio, go to the controllers folder and, within this folder, open the entries controller. Because this is the controller that you are using to handle all the API requests related to the entries. Just after the get entries method, create a new one. We said that we are going to use this endpoint to handle the post requests, so for that, we need to define in here HttpPost. Then next let us start creating this method. So I'm going to write in here public IHttpActionResult and then PostEntry. We are going to send the entry data as the part of the body of the request. So, for that, we need to define in here that the data will come from the body. So…

Contents