DEV Community

Dendi Handian
Dendi Handian

Posted on • Edited on

REST Client for your early Rest API-based project using Visual Studio Code

Imagine if your API project still in early phase development and you only code one endpoint at the moment, using Postman must be 'overkill' for the project. If you're using Visual Studio Code, you must be lucky because there is an extension that can do HTTP requests based on a file configuration named REST Client. With this extension, you can test your API project without having more HTTP client programs open in your machine, just only your beloved Visual Studio Code editor. So, let's install it in the VSCode:

rest-client-vscode

Basic GET Requests

We will be using a free public API for the demonstration, let's start by creating a file named swapi.http and let's fill the file with these requests:

### Resources List
GET https://swapi.dev/api HTTP/1.1
content-type: application/json

### People List
GET https://swapi.dev/api/people HTTP/1.1
content-type: application/json

### Planet List
GET https://swapi.dev/api/planets HTTP/1.1
content-type: application/json

### Film List
GET https://swapi.dev/api/films HTTP/1.1
content-type: application/json

### Vehicle List
GET https://swapi.dev/api/vehicles HTTP/1.1
content-type: application/json

### Starship List
GET https://swapi.dev/api/starships HTTP/1.1
content-type: application/json
Enter fullscreen mode Exit fullscreen mode

The Send Request button above each URLs should be visible when you already installed the extension, feel free click any of it to get the result like below:

rest-client-star-wars-api

Basic POST requests

Because the star wars API doesn't provide any POST request endpoint, let's try another public API named reqres.in and create another file named reqres.http and fill it with this one example POST request:

### Create An User
POST https://reqres.in/api/users HTTP/1.1
content-type: application/json

{
    "name": "morpheus",
    "job": "leader"
}
Enter fullscreen mode Exit fullscreen mode

Send the request and you have demonstrated the POST request :)

rest-client-reqres

I will cover more of the extension features later to make a request collection that more manageable and DRY, have fun to explore it first by yourself!

Top comments (1)

Collapse
 
yashdesai profile image
Yash Desai

fantastic!