The built-in IntelliJ HTTP Client is very useful for testing HTTP requests and responses.
If we want to define a variable in our .http file that is only used in this file and will not change per environment we can define it using the following syntax: @<variable name> = variable value.
The variable is an in-place variable and the scope of the variable in the current .http file.
The variable is immutable and can only be defined with a value once and cannot be overwritten.
To refer to the variable we use the syntax {{<variable name>}}.
In the following example we define a variable with the name base-url and the value https://ijhttp-example.jetbrains.com:
# We define an in-place variable "base-url"
# to be used in this file.
@base-url = https://ijhttp-examples.jetbrains.com
### GET HTML page
GET {{base-url}}/html
### GET XML page
GET {{base-url}}/xml
### GET JSON page
GET {{base-url}}/json
### GET UUID4 response
GET {{base-url}}/uuid
Written with IntelliJ 2023.3.3.