Test your apis with vscode rest client

VSCode REST Client is an extension that makes it possible to test API's directly within VSCode. The extension comes with a variety of features similar to Postman and Insomnia. VSCode REST Client has the advantage of being used within your VSCode environment.

It can be used to perform REST, cURL, GraphQL and SOAP requests. It also allows for the use of environment variables to test against different variants of your application - development, staging or production, and serves as a good API documentation tool. Another useful feature is that, it makes it possible to easily generate sample code snippets. There are several other features that you can explore for yourself.

Getting started with VSCode REST is very easy. Just install and enable the extension within VSCode.

Next, create a blank file and save it with a .rest or .http file extension.

Write your HTTP requests in standard RFC 2616 format. VSCode automatically displays a Send Request reference link above the request endpoints for you to click and see sample responses. Check a sample GET and POST request below:

@host = http://sampleapp.com
@basicAuth = Basic YWFnMixpY0BnbYrT5jb2CodI3uBVe=

### - use comment to indicate the start of a request body

POST {{host}}/api/v1/request HTTP/1.1
Content-Type: application/json
Authorization: {{basicAuth}}
{
  "origin": "achimota, accra",
  "destination": "dansoman, accra",
  "mode": "motorbike"
}

### - use comment to indicate the end of a request body			

GET https://maps.googleapis.com/maps/api/distancematrix/json?key=ZuruGaLakakuukZ6hX2jhoiejoSmtlopuF6Dnpsy7npCOyc&origins=dansoman&destinations=achimota HTTP/1.1

###

© 2023