Httpverbs in AspdotnetCore Web Api Simply
In here I am talking about httpverbs in simple manner. In Api there are no any crud words. Insted of crud words have httpverbs.
Here crud words are one the left and httpverbs are on the right.
[HttpGet]
I have made a Controller name vehicle. In the controller I have codded as bellow to in order to demonstrate httpGET.
check whether you have
then run the server.
[HttpPost]
To post something to the database we use httpPost request.Here I demonstrated through a List.
For method name we can use any name. I used post as method name. I used postman to post data.
we have to use [HttpPost] on the top of the method. Otherwise postman can’t find post method.
we post data to the List via postman body. So that we have to use [FromBody] as shown above.
[HttpPut]
It is just like httppost request. We often use it for update specific data.
from the postman we have to update data which the id=1,
[HttpDelete]
Same as the http put.
If we want to delete data which the id=1
This is the basic idea how Httpverbs works in aspdotnet Web api.In this section we have work with the controller but we have got data in a static way.Later I will show how to work with databases.