Testing our REST API
To test our REST API from Windows Terminal, we can install another dotnet tool: Microsoft's HTTP REPL. This tool allows any HTTP API to be tested, regardless of the server-side technology. To install it, run the following command in a new Windows Terminal PowerShell pane:
dotnet tool install -g Microsoft.dotnet-httprepl
We can then launch the tool by running the httprepl
command, as seen in the following screenshot. The tool will launch in a Disconnected mode, and we can connect to our API by typing the command connect <url>
, where the URL is our REST API's address (for example, https://localhost:5001
).
Once we've connected, we can use ls
to view available resources (like our WeatherForecast
) and type cd
to navigate to them. Once we've navigated to our WeatherForecast
resource, we can type GET
to run an HTTP GET command. This will call our API and return the result: