This article will discuss Testing Client for RESTful Web API. Specifically, concentrate on using VS Code to Test Web API.
Introduction
This is the structure of this article,
- Introduction
- Regular Tool for Testing Web API
- Fiddler
- Postman
- Swagger
- Alternative Tool - VS Code
- Summary
A - Web API, and the role in Microservice
In recent years, say, ten years, the Microservice Platform became popular and more popular. The reason behind this is that the Microservice decomposes the application into discrete services that implement specific business functions, often referred to as “loosely coupled,” can then be built, deployed, and scaled independently. It is the trend of software development.
Typical Microservice includes two parts: Client and API. The client is the consumer that could be applications of a smartphone, tablet, Windows, Mac, or any kind of browser. The API (Application Programming Interface) is the service provider that could be accessed by any or all of the kinds of Clients, usually indicating the RESTful service or JSON format output.
Theoretically, API could be tested by any type of its clients, whatever, console application, Web application or smartphone, and so on. However, during the development process, using a simulated tool as a client will make the development much easier.
The popular tools we used to test Web API, such as,
However, in some situation, for example, some company has a very strict security policy, this kind of tool is blocked. We have another choice is to use Swagger that is a default Web API testing tool built in Microsoft .NET Core Web API development (for .Net Framework, if you want to use Swagger, you have to add it by yourself). For using Swagger, one might see my previous article, ASP.NET Core, Web API - Entity Framework Call Stored Procedure, However, the shortcoming for Swagger is it is an application built-in testing tool for Web API.
So, an alternative tool for Fiddler, Postman, or Swagger for testing Web API is necessary for some special situations. One of my colleagues suggested that VS Code with REST Client extension can do the job. This is what I will introduce in the next section.
B - Testing RESTful Web API by VS Code
These two links are what I got from my colleague, those are enough for our state to use VS Code as a testing client for Web API,
- REST Client --- Visual Studio Market Place
- The Best way to test your REST API Code | Test Rest API with VSCode --- youtube
B - 1: Install REST Client
In VS Code environment: Click Manage (Left Bottom Corner) => Extensions (or Ctrl+Shift+X).


In Extensions: Marketplace: type in 'Rest' to search, you'll see the extensions: REST Client.

You will get REST Client, and install,

B - 2: Open a file to Use REST Client Testing Web API
After installing REST Client extension, the next step will be very straightforward,
1, Open a file and use it to test Web API











E.Prados ValientePosted Aug 31, 2022, 7:42 AM
How-to do unit testing for external API (like Fake API ) api.chucknorris.io ? **[simple-example-of-calling-rest-api-with-httpclient-in-net5.0](https://adamstorr.azurewebsites.net/blog/simple-example-of-calling-rest-api-with-httpclient-in-net5.0)**