Dotnet logo

.NET Tools

Essential productivity kit for .NET and game developers

.NET Tools

HTTP Client Tools Everywhere!

One of JetBrains Rider’s greatest assets is that it is part of the IntelliJ platform family of products. So when JetBrains develops a tool for one ecosystem, it is likely to help others, and in your case, the .NET ecosystem. In this post, we’ll explore IntelliJ HTTP Client CLI, one of the newer additions to our tool offerings and, hopefully, the latest tool in your toolbox.

IntelliJ HTTP Client

Our IDEs, including JetBrains Rider, have supported .http and .rest files for several years now, and developers love using the files to perform HTTP requests, assert responses, and build a test suite of integration tests. We’ve also added support for GraphQL, gRPC calls, and WebSockets allowing web developers to test a range of web applications never before possible. We also support protocol-level features, such as cookie management, SSL/TLS support, and HTTP proxy settings. Here’s a quick sample of what you might expect to see in a request file.

### GET request with a header
GET https://httpbin.org/ip
Accept: application/json

### GET request with a parameter
GET https://httpbin.org/get?show_env=1
Accept: application/json

### GET request with environment variables
GET {{host}}/get?show_env={{show_env}}
Accept: application/json

### GET request with disabled redirects
# @no-redirect
GET http://httpbin.org/status/301

### GET request with dynamic variables
GET http://httpbin.org/anything?id={{$uuid}}&ts={{$timestamp}}

###

While the request file format can be as simple as you’d like, we also provide an array of notable editing enhancements, including code highlighting, code completion specific to your current project, reformatting, inline documentation, language injections in request bodies for JSON, XML, and other web languages. These quality-of-life improvements make writing these files a joy.

To start with the HTTP Client in JetBrains Rider:

  1. Add a .http or .rest file to your current solution or in the scratch folders in the solution explorer. Once created, you’ll see an *Examples link in the upper-right corner of the editor. 
  2. You can also head over to our HTTP Client documentation, which provides in-depth information about every aspect of our implementation.

Running the HTTP Client in your favorite .NET editor is only part of the story. Recently the IntelliJ team made the HTTP Client engine available to everyone via a CLI and Docker version. Let’s look at how to install it and where you might want to use it.

IntelliJ HTTP Client CLI

With the popularity of our HTTP Client, we decided to share the love with other team members by providing the same execution engine outside of our editors. The CLI allows folks using other editors and IDEs to share .http files and gain value from a shared library of tests.

You can get the HTTP Client CLI as a Docker image or ZIP archive.

To get the HTTP Client CLI as a Docker image, pull the image:

docker pull jetbrains/intellij-http-client

To get a ZIP archive, use cURL or download the file directly:

curl -f -L -o ijhttp.zip "https://jb.gg/ijhttp/latest"

Note that the ZIP distribution requires JDK 17+ on your local development environment.

Once installed, you can pass any number of files to the CLI tool and watch the output for requests completed and for any failed tests.

intellij http client CLI tool running in terminal on macOS

Be sure to check the command-line variables by running ijhttp –help to see all the available configuration options available to you, and there are many options.

You can also use the CLI tool in CI/CD scenarios to help foster a sense of shared understanding and to double as another set of integration tests. The tool can also export all results to a JUnit-compatible XML file, which you can convert to an HTML report in all your favorite build environments, such as TeamCity, GitHub Actions, and GitLab. 

Our developer advocate colleagues go into full depth about CLI options in our latest Webinar, so we highly recommend you check it out.

Conclusion

The JetBrains HTTP Client is a fully featured tool that supports RESTful APIs and other protocols such as GraphQL and gRPC. You can write request files in .http files in the editor and benefit from your work in environments like CI/CD. We also help team members with different tools work in a shared codebase. After all, sharing is caring, and teamwork makes the dream work.

While you’ve got web requests on the brain, I recommend you read our article on our Endpoints tool window. It’s a great addition to your workflow and can help quickly generate requests.

As always, thanks for reading, and please leave any comments or suggestions below.

image credit: Adolfo Félix

image description

Discover more