Recently, I had to create a REST web API project. We had a requirement of communicating from Office 365 apps to the on-premise database. So, we thought of creating APIs hosted on a local server, exposed out of a firewall, and performing the required operations on the database. Let’s see the basics of it.
Create REST Web API project
If you don’t have Visual Studio installed, you can easily download the latest Community Edition (free) and install it on your machine.
Open Visual Studio >> Add New Project >> select “ASP.NET Web Application (.NET Framework)” project template >> Give a meaningful name to the project and click OK.

On the next screen, select “Web API” template and click OK.

A Web API project with default controller and default methods gets created, as shown below.

Run the project to test it (click F5) >> by default, Internet Explorer browser will open. Copy the root URL and hit the below API in Chrome or Firefox browser to see the XML/JSON response API endpoint - /api/values.

You can publish the project to Azure web API or local drive. If you want to host this API to on-premise server IIS, then copy the published folder content and paste it in the virtual directory of your IIS site.
Add multiple POST methods
Now let’s see how we can add multiple posts or for that matter, any methods in one controller.
Open your controller class, in our project its ValuesController.cs >> Copy paste below code, these are two sample post methods with a string input and return parameter – you can write your business logic in it. Similarly, you can add any number of POST, GET, PUT, DELETE methods in one controller.





Nkabirwa IsmailPosted Oct 16, 2019, 3:41 PM
I get multiple actions were found that match the requests
Nkabirwa IsmailPosted Oct 16, 2019, 3:40 PM
It does not seem to work!!
DeepanPosted Jul 13, 2019, 1:01 AM
Thanks for sharing