Backend Development 9 min read

Boost Your API Testing: Master IntelliJ IDEA’s Built‑in HTTP Client

During remote work, the author discovers how IntelliJ IDEA’s integrated HTTP Client can replace external tools like Postman, offering in‑IDE request creation, environment variables, response scripts, and plugin extensions to streamline API development, testing, and collaboration across multiple product lines.

macrozheng
macrozheng
macrozheng
Boost Your API Testing: Master IntelliJ IDEA’s Built‑in HTTP Client

Background

During the pandemic many developers work from home and need to test new API interfaces without leaving the IDE.

Why Postman Falls Short

Mouse‑heavy navigation

Importing others' data for debugging

Unclear environment‑variable view

Switching between IDE and Postman

Difficult to locate requests

Introducing IntelliJ IDEA HTTP Client

The built‑in HTTP Client lets you create, edit and execute HTTP requests directly in the editor.

Enabling the Plugin

Open

Tools → HTTP Client → Test RESTful Web Service

and follow the prompt to enable the plugin.

Creating an HTTP Request File

Press

⇧⌘N

and choose HTTP Request (saved in Scratches).

Or use

File → New → HTTP Request

to store the file in the project, allowing version control.

Editing a Request

Typical workflow: a POST login request obtains a token, then the token is added to the

Authorization

header of subsequent requests.

Advanced Features

Environment Variables

Variables are written as

{{variable}}

and defined in JSON files such as

http-client.env.json

or

http-client.private.env.json

(the latter overrides the former).

<code>{
  "dev": {
    "host": "localhost",
    "port": 8081,
    "identifier": "tanrgyb",
    "password": "iloveu"
  },
  "prod": {
    "host": "dayarch.top",
    "port": 8080,
    "identifier": "admin",
    "password": "admin"
  }
}
</code>

Response Handler Scripts

Use embedded scripts or external files to extract data from a response and store it as a global variable.

<code>GET {{host}}:{{port}}/login
Content-Type: application/json
Accept: application/json

> {%
client.global.set("auth_token", response.body.result.token);
%}
</code>

Later requests can reuse the token with

Authorization: Bearer {{auth_token}}

.

Additional Helpers

Plugins such as RestfulToolkit display all project interfaces in a side panel, and the shortcut

cmd+\

quickly finds a request by keyword.

Live Templates let you define custom request snippets, and the JSON Viewer Chrome extension formats JSON responses directly in the browser.

Conclusion

The IDEA HTTP Client together with these auxiliary tools solves the pain points described at the beginning, providing an efficient, IDE‑centric workflow for API development and testing.

References

Testing RESTful web services – JetBrains documentation

IntelliJ IDEAAPI testingHTTP ClientEnvironment VariablesPostman alternativeresponse scripts
macrozheng
Written by

macrozheng

Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.