In VS 2022, there is a new feature that can be useful to test our APIs.
In case we do not have Swagger, we can use Endpoint Explorer from VS and can test and play with API’s endpoints.
Steps
Open any API project and go to View->Other windows->Endpoint Explorer as per the screen below.
After opening Endpoint Explorer, we have the left window from where we can see all the listed API endpoints in applications.
Let’s Invoke
Right-click on the endpoint and click on Generate Request.
We will have the window below. We can click on the send request button and get a response.
We will get a response in the new window as below.
GET by ID. I have updated the ID as per the request URL and got the corresponding response.
Next Step
We can save this above middle window as a file with a .http extension and can use it next time without going to Endpoint Explorer. We can say this file is a ready-made rest client for playing and testing our endpoint.
I saved the above file and used the next file for testing purposes.
Thanks