In the previous articles of the ASP.NET Web API series, I’ve used the Get() method of HTTP to make a lot of requests by which we can get a member or read the data. Hence, to retrieve the information as per our expectations, we use the HttpGet method by using a URL. In this article of the series, I’ll work on the Post() method of HTTP. You can follow the ASP.NET Web API series for the purpose of learning how the Get() method request works in the following links –
In this, I will show you how we can send the data, which will be saved in my SQL database by using Post() method. Hence, just flip to Visual Studio and open your previous project.
Under the IEmployeTest Interface, create a method to insert a record of an employee, followed by the table name, that is Employee.
- string insertEmploye(Employe emp);
Here is the screenshot of IEmployeInterface -
- public string insertEmploye(Employe emp)
- {
- EmployeeEntities EM = new EmployeeEntities();
- Employe ems = new Employe();
- ems.EmpID = emp.EmpID;
- ems.EmpName = emp.EmpName;
- ems.EmpAddress = emp.EmpAddress;
- ems.EmpMoNo = emp.EmpMoNo;
- ems.EmpProfession = emp.EmpProfession;
- EM.Employes.Add(ems);
- EM.SaveChanges();
- return "Hey!! congrates.. Amit your Employee data is saved successfully";
- }

In the Employecontroller, I need to call insertetEmploye() method with the help of empTest.
- [HttpPost]
- public string InsertEmploye(Employe em)
- {
- return empTest.insertEmploye(em);
- }
Here is the screenshot of Employee controller:

All is set now and we can call the POST method, using Postman.
API Testing with Postman
Postman is a tool that interacts with HTTP APIs and produces HTTP methods which you want to return. Postman is responsible to create, send, and save HTTP requests and afterwards test the response data which you want to expect. Postman is a Google Chrome app, which also has powerful testing features.
In the Header tab, I need to specify what kind of response a client can accept. It is a HTTP header. In Postman, we can change the data in different formats. If we want to get our data in JSON format, we need to write:
Key = Content-Type value = application/json
Hence, the content-type is our key and Application/json is our value. Under the value, we can pass our response data in whichever format we want to return the data.

I want to call Post method. Hence, select POST method from the list of HTTP methods.
We try and pass the Web API URL in the URL tab in order to make sure you need to first run your project and pass localhost URL.

Go to body panel and select row. Under the row, write the JSON script of your data which you want to save in the database. After writing the JSON script of employee data, click the Send button of the Window.

Hence, you can see my data has been saved successfully. You can refer to the history of your all operations in the left side of the Postman Window.

Let’s check in to SQL Server Management. I have my table of Employee names and finally we saved the data in my table.

Sankeerth MaragantiPosted Jun 27, 2018, 5:25 AM
System.Data.Entity.Infrastructure.DbUpdateException HResult=0x80131501 Message=Unable to update the EntitySet 'Employee' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
Chris LovePosted Feb 28, 2018, 3:47 PM
So happy you included postman instructions!
RajaPosted Jun 27, 2016, 6:31 AM
Good One....
Amit MishraPosted Jun 27, 2016, 12:05 AM
Thanks to all
Vignesh ManiPosted Jun 26, 2016, 4:40 PM
Nice
Guest UserPosted Jun 25, 2016, 10:43 AM
cool show! postman I like using it to test APIs
Debasis SahaPosted Jun 25, 2016, 2:52 AM
Nice one..
kalu singh raoPosted Jun 25, 2016, 12:01 AM
Nice...
Santhakumar MunuswamyPosted Jun 24, 2016, 11:59 PM
Thank you for nice article