Data Driver

Blog archive

VS Code Quick Tip: Install Curl to Speed Up REST API Testing

While mostly known for its use in Linux-based development, the versatile curl tool for transferring data over HTTPS can be a nifty timesaver when using Visual Studio Code on Windows.

Specifically, this reporter has found it useful for quickly testing the results of a REST API call.

For example, when wrestling with how to display JSON data in a list view, I want to make sure the URL I'm using for a GET request to a REST API is actually returning data and see exactly how that JSON data is presented.

With the integrated terminal window in VS Code, this oft-repeated task becomes much faster. Rather than having to exit VS Code and go to a browser to see a URL -- say "https://jsonplaceholder.typicode.com/posts" -- and view the results, I can just quickly go to the terminal window -- right below my code -- and type: curl https://jsonplaceholder.typicode.com/posts.

That gives me this:

Instant REST API Response as JSON
[Click on image for larger view.] Instant REST API Response as JSON

The free, open source curl tool, originally developed by Daniel Stenberg 20 years ago (see Wikipedia page), is extremely versatile and super simple to install.

For me, on a 64-bit Windows 7 machine, installation was as quick as going to the download page and finding the correct package for that configuration. Unzipping it produces just two files -- curl.exe and ca-bundle.crt -- that need to be placed in a directory so the executable is in the path of your terminal window.

As far as versatility, you can find a dizzying array of potential use cases on the "Manual -- curl usage explained" page.

The tool's home page lists an almost equally dizzying number of supported protocols, and more information:

Instant REST API Response as JSON
[Click on image for larger view.] Instant REST API Response as JSON (source: Curl Site).

Curl functionality can also be found in the REST Client extension offering on the VS Code Marketplace, where one of the tool's features is listed as the ability to "Send CURL command in editor and copy HTTP request as CURL command."

More information on testing REST APIs with curl can be found in the appropriately titled article "How to test a REST API from command line with curl" on the CodingpediaOrg site.

Posted by David Ramel on 07/31/2017


comments powered by Disqus

Featured

  • Hands On with Microsoft's AI Playground in a Windows App

    Microsoft reintroduced the AI Dev Gallery, a Windows application that serves as a comprehensive playground for AI development using .NET. It simplifies AI development with .NET through interactive samples, easy model downloads, and exportable source code.

  • Vibe Coding Advances in Visual Studio 2022 Previews

    Preview 3 features next edit suggestions -- or tab, tab, tab coding -- following previous previews of GPT-4o code completions and assorted Copilot enhancements.

  • Mastering Modern JavaScript

    Master the latest features of modern JavaScript in a hands-on workshop covering clean code techniques, async programming, templating, and full-stack development with Node.js.

  • Nadaraya-Watson Kernel Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of Nadaraya-Watson kernel regression using the C# language. NW kernel regression is simple to implement and is especially effective for small datasets.

  • Mapping OpenAI's Full AI Suite After Codex CLI Debut

    Helping developers sort out which AI does what amid the growing clutter.

Subscribe on YouTube