This tutorial describes how to test using Postman GET, POST, PUT, Delete http methods created by ASP.NET Web API. You can test the API using Fiddler or SOAP UI or Postman. For this tutorial we will use Postman.
Download Postman debugging tool and install.
Once it is installed, open postman tool from Start menu.
You can visit CRUD operations using ASPNET Core and implement CRUD API using ASP.NET Core Web API. It creates a sample application which creates Create, Read, Update and Delete http methods and works with inmemory database to store data.
Once you have implemented API, you can launch Web API application to see the result of Get method in Browser. Now your APIs are running on Kestrel server and you must be seeing localhost url in browser like http://localhost:<portnumber>/api/supplier.
Open Postman tool if it is not open. You will see two pane in screen. Left pane shows the history of the Rest URL's which you already used and collection tab using which you can create collection or import collection. And right side pane you can make new request to API and see response.
From Postman tool - right pane select GET from DropDown, then enter your Web API url like http://localhost:<portnumber>/api/supplier and click on Send button.
This will make a request to Web API server and get response. You can get response in JSON, XML, HTML, Text format.
In this step you will test HTTP Post Web API method with postman. Web API method JSON object in FromBody. Request will contain JSON object which Web API will convert into Model and create a record into database.
In postman follow below steps to use Post method.
HTTP Put is used to Create or Update entity. The differenece between PUT and POST is, PUT is idempotent meaning that you call PUT n number of times, it will only modify existing entity if it is already existing else it will create a new entity. POST is not idempotent meaning if you call POST n number of times it will create new entities n number of times.
To update existing entity, client needs to provide entire entity details with updated values for all attributes.
In postman follow below steps to use Put method.
HTTPDelete method is responsible to delete existing entity from data store. If HTTPDelete request has entity body the body is ignored. So you can send the entity body with request however it has no use.
If Delete requests found required entity does not exist it returns 404 - Not Found response code. If requested entity exists
it deletes from data store and return 200 - Ok as Http Response, if response has content describing status.
It returns 204 - No Content if response does not have any content.
In postman follow below steps to use Delete method.