Skip to content

VSCode REST Client

VSCode REST Client is a Visual Studio Code extension that allows you to execute HTTP requests directly within the editor.^[600-developer-tools-vscode-restclient-postman.md]

Features and Usage

The extension allows users to define variables and send REST requests using standard .rest or .http files.^[600-developer-tools-vscode-restclient-postman.md] It simplifies the process of testing APIs by removing the need to switch between an editor and an external tool like Postman.

Syntax and Variables

Requests are written in plain text within the editor, using standard HTTP methods (e.g., GET, POST).^[600-developer-tools-vscode-restclient-postman.md] The extension supports variable definition and substitution to manage dynamic values such as domains, tokens, or content types.

Example Configuration:

@localhostBWS = http://localhost:8080/business-web-service/resources
@UserAgent = Mozilla/5.0 (Windows NT 10.0; Win64; x64) ...
@ContentType = application/json
@domain = {{localhostBWS}}
^[600-developer-tools-vscode-restclient-postman.md]

Request Chaining

A key feature of the REST Client is the ability to chain requests using ### separators and extract values from responses for subsequent requests.^[600-developer-tools-vscode-restclient-postman.md]

Example Request:

# @name loginCWS
POST {{domain}}/sessions HTTP/1.1
User-Agent : {{UserAgent}}
Content-Type : {{ContentType}}

{
    "operatorName": "tommyyyy",
    "password": "tommyyyy",
    "language": "zh-cn"
}

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

# @name allMission/count
GET {{domain}}/workflow/allMission/count
Authorization : {{authToken}}
^[600-developer-tools-vscode-restclient-postman.md]

In the example above, the loginCWS request is executed first. The authToken variable is then extracted from the response body (loginCWS.response.body.$.id) and used in the Authorization header of the following request.^[600-developer-tools-vscode-restclient-postman.md]

  • [[Postman]] (for comparison regarding API testing and script handling)
  • [[VSCode]]

Sources

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