Menu

Cool extensions for Visual Studio Code: Rest Client

We have all come across the need to test a Web API, many of us use Postman or Fiddler for that purpose, but…. What if I told you, you could test it from within Visual Studio Code?

Let me introduce you to an extension I recently discovered, REST Client - Visual Studio Marketplace. As its name suggests, it is a REST client, but inside VS Code, isn't it amazing? 

Interesting, but how do I use REST Client? 

 

The first thing is to install the extension. You can search in the Visual Studio's marketplace or install it from this link, REST Client - Visual Studio Marketplace.

 

Once installed, let's use it!. I'm going to use it with the Forecast API that dotnet create by default.

 

I like to create a folder inside the project called “Requests” and inside it, we are going to create a file. You can name it whatever you want, it has to end with the .http extension. 

 

 

In my case, I'm going to name it WeatherForecast.http, so it will only contains the WeatherForecast requests.


And now, inside this file, we will write our request. First we start with the method and then the address. 

 

If everything is correct, we will see a small button appear above our code to send the request. We will see the response in a new window that will open. Isn't it amazing? Without leaving Visual Studio.

You will have some questions, for example how to POST a JSON, but first let me show you how to use variables.

It is quite simple, we will go to the beginning of the file and with @VariableName, we will have it done. 

Let's create one for our host.

Now let's go with the POST, we are going to place the request in the same http file. To be able to do this, we have to put three “#” to isolate it from the other. 

We put the method to use and the content-type, in my case JSON

 

And voilà! , I hope it was helpful, and I'll see you in another part of Cool Extensions for Visual Studio Code.

 

 

What did you think? If you have any questions or need help with a project, don't hesitate to contact us. 

We will be happy to help youūüėä

 

dotnet new webapi
 
 
dotnet new webapi
 
 
dotnet new webapi
 
 
Categories
Related posts
Why should HR management be in the cloud?
Sergio Darias P√©rez  |  29 November 2022

We explain why more and more HR departments are implementing cloud technology and data-driven applications for their daily management.

Read more
How to set up FSLogix in a storage account
Carlos Fern√°ndez Barreiro  |  09 November 2022

In this post we explain how to complete a storage account setup process for Fslogix profile deployment

Read more
Microsoft Teams, much more than meetings and video calls
Silvia Padilla Rodr√≠guez  |  02 November 2022

In this post we discover why Microsoft Teams has become the core of many organizations to optimize daily operations

Read more