HttpRepl is a light-weight utility from Microsoft used to test REST APIs and view their results. It can run on any O/S that .NET Core (or .NET 5 and later) runs on. HttpRepl is an open-source project on GitHub at https://github.com/dotnet/HttpRepl. It is an alternative to Postman.
Companion video: https://youtu.be/RLdnXN4OAPg
To install the HttpRepl, run the following command from within a terminal window:
dotnet tool install -g Microsoft.dotnet-httprepl
To update HttpRepl to the latest version, enter the following command:
dotnet tool update -g Microsoft.dotnet-httprepl
On Windows, this tool gets installed at:
%USERPROFILE%\.dotnet\tools\httprepl.exe
Let us test HttpRepl with a REST API service located at https://api4all.azurewebsites.net. From within a terminal window, enter the following command:
httprepl https://api4all.azurewebsites.net
You are advised to associate the HttpRepl utility with a text editor so that you can compose your POST & PUT requests. The below terminal window command will associate Notepad.exe (in Windows) with HttpRepl:
pref set editor.command.default "C:\Windows\system32\notepad.exe"
This shows us that we can do GET, POST, PUT and DELETE. Entering the id is necessary for DELETE, PUT and retrieving one Student (GET by id).
Let us retrieve all Students data by entering GET:
This was the output I got:
I entered data as follows, using the same ID as before, and changing
only school to nursing. I then saved the document before closing it:
This is the output I received:
I then did a GET to see all students:
I hope you found HttpRepl a useful utility.
No comments:
Post a Comment