Skip to content

REST Client request syntax

REST Client request syntax refers to the plain-text format used by tools like the VS Code REST Client extension to define and execute HTTP requests directly from an editor^[600-developer-tools-vscode-restclient-postman.md].

Request Structure

Requests are defined using standard HTTP methods followed by the target URL^[600-developer-tools-vscode-restclient-postman.md]. The structure explicitly specifies the protocol version (e.g., HTTP/1.1)^[600-developer-tools-vscode-restclient-postman.md]. Headers are added on subsequent lines using a Key-Value format^[600-developer-tools-vscode-restclient-postman.md]. The request body is placed after a blank line, typically formatted as JSON^[600-developer-tools-vscode-restclient-postman.md].

Request Example

POST http://localhost:8080/business-web-service/resources/sessions HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
Content-Type: application/json

{
    "operatorName": "tommyyyy",
    "password": "tommyyyy",
    "language": "zh-cn"
}
^[600-developer-tools-vscode-restclient-postman.md]

Syntax Elements

Variables and Environments

The syntax supports defining variables to reuse values such as base URLs or common headers^[600-developer-tools-vscode-restclient-postman.md]. Variables are defined at the top of the file using the @ symbol^[600-developer-tools-vscode-restclient-postman.md]. These variables are then referenced in the request using double curly braces (e.g., {{domain}})^[600-developer-tools-vscode-restclient-postman.md].

@localhostBWS = http://localhost:8080/business-web-service/resources
@domain = {{localhostBWS}}

GET {{domain}}/path
^[600-developer-tools-vscode-restclient-postman.md]

Request Separators

Requests within the same file are separated using a delimiter sequence consisting of three hash signs (###)^[600-developer-tools-vscode-restclient-postman.md].

Chaining Requests

Requests can be named and chained to extract data from one response to use in another^[600-developer-tools-vscode-restclient-postman.md]. A special comment # @name assigns an identifier to a request^[600-developer-tools-vscode-restclient-postman.md]. Subsequent requests can then access the response body of the named request using the syntax {{requestName.response.body.$.jsonKey}}^[600-developer-tools-vscode-restclient-postman.md].

# @name loginCWS
POST {{domain}}/sessions HTTP/1.1
###

@authToken = {{loginCWS.response.body.$.id}}

GET {{domain}}/protected
Authorization: {{authToken}}
^[600-developer-tools-vscode-restclient-postman.md]

  • [[HTTP]]
  • [[REST API]]
  • [[API Testing]]

Sources

  • 600-developer-tools-vscode-restclient-postman.md