How To Implement the Restful Web Services Get and Post Methods In asp.net and its hit the postman
Please Help Fast.....!
How To Implement the Restful Web Services Get and Post Methods In asp.net and its hit the postman
Please Help Fast.....!
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Tuhin PaulPosted Mar 16, 2023, 5:02 AM
You can try the steps below:
1) Create a new ASP.NET project in Visual Studio.
2) Add a new Web API Controller to your project by right-clicking on the Controllers folder and selecting "Add -> Controller".
3) In the "Add Scaffold" dialog, select "API Controller - Empty" and click "Add".
4) In the new controller file, add the following code to implement the GET method:
This code retrieves data from a data source and returns it as a list of strings in the HTTP response body.
5) To implement the POST method, add the following code to the controller:
This code takes a string value from the HTTP request body and saves it to a data source. It then returns a "201 Created" response with the new value in the Location header.
6) Build and run the project in Visual Studio.
7) To test the GET method, open Postman and create a new request. Set the request method to GET and enter the URL of your API endpoint. Send the request and you should receive a response with the data returned by the GET method.
8) To test the POST method, create a new request in Postman and set the request method to POST. Enter the URL of your API endpoint and set the body of the request to a string value. Send the request and you should receive a "201 Created" response with the new value in the Location header.
Naimish MakwanaPosted Mar 16, 2023, 4:21 AM
Hello Tarun,
Please use below link:
To build Restful Service:
https://learn.microsoft.com/en-us/aspnet/web-api/overview/older-versions/build-restful-apis-with-aspnet-web-api
https://dzone.com/articles/step-by-step-how-to-develop-a-restful-web-service
To Test using Postman
https://dotnettutorials.net/lesson/how-to-use-postman-to-test-web-api/
https://www.c-sharpcorner.com/article/how-to-test-api-web-service-in-asp-net-core-5-using-postman/
Thanks
Naimish Makwana