VLT-Website-Heading

How to use Visual Studio Code to run curl commands

Jul 16, 2020 7:36:16 PM / by Vu Long Tran

This guide is to show you how to run similar commands using Microsoft's Visual Studio Code environment.

As Visual Studio Code is also free. Built on open source and runs everywhere. The biggest benefit I can see is the availability of extensions which can further enhance your programming and testing experiences. 

You may be using Postman, Terminal or another tool to run some of your API testing and various commands. This will be similar. 

How to use Visual Studio to run curl commands

Step 1 - Download Visual Studio Code (if you haven't already) 

You can download Visual Studio from Microsoft's website at https://code.visualstudio.com/.

visual-studio-code

Step 2 - Add REST Client to your Visual Studio

Add REST Client to your Visual Studio. You do this by adding the "REST Client" extension. There are alternative options available, but I like the "REST Client" that is available there. (Github brief from the developer here)

REST-Client

Step 3 - Open new file in your Visual Studio

Open new file in your Visual Studio.

New-file

Step 4 - Open the Command Palette in your Visual Studio

Open the Command Palette in your Visual Studio. It is under View> Command Palette. 

Hotkey is Ctrl+Shift+p.

Step 5 - Search for "Change Language Mode" in your Visual Studio

Search for "Change Language Mode" in your Visual Studio and change the language to HTTP.

select-language-mode

Step 6 - Type in your curl commands in your Visual Studio

Type in your usual curl commands in your Visual Studio and when you are ready, click on "Send Request".  

Hotkey is Ctrl+Alt+r.

send-request

Here is an example:

curl -vso /dev/null/ www.vulongtran.com

curl-example

Step 7 - Enjoy running your curl and API testing in your Visual Studio

Enjoy running your curl and API testing in your Visual Studio.

You can also use this to submits your REST API requests. As it will act similar to what you may be familiar with via Postman. Where you can enter a request URI along with required HTTP request headers and parameters, send the request, and see the response data.

Topics: tech, web development, microsoft, apis, developer

Vu Long Tran

Written by Vu Long Tran

Solutions Engineer APAC. ex-@Forrester consultant. Writing on #cloud #howto guides and #tech tinkering!