### HTTP Request Line Examples Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Examples of valid request lines. If the method is omitted, it defaults to GET. Ensure the file language mode is set to 'HTTP' or 'plaintext'. ```http GET https://example.com/comments/1 HTTP/1.1 ``` ```http GET https://example.com/comments/1 ``` ```http https://example.com/comments/1 ``` -------------------------------- ### Export Environment Variable Example Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Example of exporting environment variables in a shell configuration file. ```bash export DEVSECRET="XlII3JUaEZldVg=" export PRODSECRET="qMTkleUgjclRoRmV1WA==" export USERNAME="sameUsernameInDevAndProd" ``` -------------------------------- ### OTP Authentication Example Source: https://context7.com/huachao/vscode-restclient/llms.txt Example of sending an OTP for multi-factor authentication. Ensure the host, username, password, and otp variables are defined. ```http # @prompt otp One-time code from your authenticator app POST {{host}}/auth/mfa HTTP/1.1 Content-Type: application/json { "username": "{{username}}", "password": "{{password}}", "otp": "{{otp}}" } ``` -------------------------------- ### Using System Variables in a POST Request Source: https://github.com/huachao/vscode-restclient/blob/master/README.md An example demonstrating the usage of various system variables within a POST request, including dotenv, guid, timestamp, randomInt, datetime, and localDatetime. ```http POST https://api.example.com/comments HTTP/1.1 Content-Type: application/xml Date: {{$datetime rfc1123}} { "user_name": "{{$dotenv USERNAME}}", "request_id": "{{$guid}}", "updated_at": "{{$timestamp}}", "created_at": "{{$timestamp -1 d}}", "review_count": "{{$randomInt 5 200}}", "custom_date": "{{$datetime 'YYYY-MM-DD'}}", "local_custom_date": "{{$localDatetime 'YYYY-MM-DD'}}" } ``` -------------------------------- ### Send Simple GET Request Source: https://context7.com/huachao/vscode-restclient/llms.txt Use this syntax for a basic GET request. The method defaults to GET if not specified. ```http ### Simple GET — implicit method defaults to GET https://jsonplaceholder.typicode.com/posts/1 ``` -------------------------------- ### SSL Client Certificates Configuration Source: https://context7.com/huachao/vscode-restclient/llms.txt Configuration example for using SSL client certificates with VS Code settings. ```APIDOC ## SSL Client Certificates ### Description Configures per-host SSL client certificates in VS Code settings. ### Request Example ```jsonc // .vscode/settings.json { "rest-client.certificates": { "api.example.com": { "cert": "/Users/me/certs/client.crt", "key": "/Users/me/certs/client.key" }, "localhost:8443": { "pfx": "/Users/me/certs/client.p12", "passphrase": "mysecret" } } } ``` ```http GET https://api.example.com/secure-endpoint HTTP/1.1 Accept: application/json ``` ``` -------------------------------- ### Get Subscriptions (Force Re-authentication) Source: https://github.com/huachao/vscode-restclient/wiki/Azure-Active-Directory-Authentication-Samples This sample demonstrates how to force re-authentication for the current directory, useful for switching accounts. ```APIDOC ## GET https://management.azure.com/subscriptions ### Description Forces re-authentication for the current directory, effectively clearing the token cache and prompting for new credentials. This is useful for switching accounts. ### Method GET ### Endpoint https://management.azure.com/subscriptions ### Query Parameters - **api-version** (string) - Required - Specifies the API version to use. ### Headers - **Authorization** (string) - Required - Bearer token for Azure AD authentication, with the `new` keyword to force re-authentication. ### Request Example ```http GET https://management.azure.com/subscriptions ?api-version=2017-08-01 Authorization: {{$aadToken new contoso.com}} ``` ### Notes - The `new` keyword must be specified first. - The token cache is cleared in memory when Visual Studio Code restarts. It can also be cleared manually via `F1 > Rest Client: Clear Azure AD Token Cache`. ``` -------------------------------- ### Get Subscriptions (Default Directory) Source: https://github.com/huachao/vscode-restclient/wiki/Azure-Active-Directory-Authentication-Samples This sample shows how to retrieve subscriptions using the default directory for the authenticated account. ```APIDOC ## GET https://management.azure.com/subscriptions ### Description Retrieves a list of subscriptions for the authenticated Azure AD account using the default directory. ### Method GET ### Endpoint https://management.azure.com/subscriptions ### Query Parameters - **api-version** (string) - Required - Specifies the API version to use. ### Headers - **Authorization** (string) - Required - Bearer token for Azure AD authentication. Uses the default token cache. ### Request Example ```http GET https://management.azure.com/subscriptions ?api-version=2017-08-01 Authorization: {{$aadToken}} ``` ``` -------------------------------- ### SOAP Request Example Source: https://context7.com/huachao/vscode-restclient/llms.txt Demonstrates how to construct a SOAP request with the necessary headers and XML body. This is useful for interacting with SOAP-based web services. ```http POST https://www.w3schools.com/xml/tempconvert.asmx HTTP/1.1 Content-Type: application/soap+xml; charset=utf-8 SOAPAction: "https://www.w3schools.com/xml/CelsiusToFahrenheit" 36.6 ``` -------------------------------- ### Example Swagger/OpenAPI Import - REST Client Source: https://context7.com/huachao/vscode-restclient/llms.txt An excerpt from a Swagger/OpenAPI file demonstrating the structure that will be converted into REST Client .http request blocks. ```yaml # Example petstore.yaml excerpt — after import, generates blocks like: # GET https://petstore.swagger.io/v2/pets HTTP/1.1 # Accept: application/json # # ### # # POST https://petstore.swagger.io/v2/pets HTTP/1.1 # Content-Type: application/json # # { # "name": "", # "tag": "" # } ``` -------------------------------- ### Digest Auth Example Source: https://context7.com/huachao/vscode-restclient/llms.txt Example of using Digest Authentication with username and password. This format is specific to Digest authentication challenges. ```http GET https://httpbin.org/digest-auth/auth/user/passwd HTTP/1.1 Authorization: Digest user passwd ``` -------------------------------- ### Basic Authentication Examples Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Demonstrates three equivalent ways to configure Basic Authentication in REST Client requests. Ensure the Authorization header is correctly formatted for username and password. ```http GET https://httpbin.org/basic-auth/user/passwd HTTP/1.1 Authorization: Basic user:passwd ``` ```http GET https://httpbin.org/basic-auth/user/passwd HTTP/1.1 Authorization: Basic dXNlcjpwYXNzd2Q= ``` ```http GET https://httpbin.org/basic-auth/user/passwd HTTP/1.1 Authorization: Basic user passwd ``` -------------------------------- ### OTP Authentication Source: https://context7.com/huachao/vscode-restclient/llms.txt Example of how to send an OTP (One-time code) for multi-factor authentication. ```APIDOC ## POST /auth/mfa ### Description Sends an OTP for multi-factor authentication. ### Method POST ### Endpoint {{host}}/auth/mfa ### Request Body - **username** (string) - Required - The user's username. - **password** (string) - Required - The user's password. - **otp** (string) - Required - The one-time code from the authenticator app. ### Request Example ```json { "username": "{{username}}", "password": "{{password}}", "otp": "{{otp}}" } ``` ``` -------------------------------- ### Request with SSL Client Certificate Source: https://context7.com/huachao/vscode-restclient/llms.txt An example HTTP request that will automatically use the configured SSL client certificate for 'api.example.com'. ```http GET https://api.example.com/secure-endpoint HTTP/1.1 Accept: application/json ``` -------------------------------- ### HTTP Request Headers Example Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Shows standard 'field-name: field-value' format for request headers. A default 'User-Agent' is added if not specified, which can be configured. ```http User-Agent: rest-client Accept-Language: en-GB,en-US;q=0.8,en;q=0.6,zh-CN;q=0.4 Content-Type: application/json ``` -------------------------------- ### SOAP Request Example Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Send a SOAP request. The extension provides snippets to help construct SOAP envelopes. ```http POST https://www.w3schools.com/xml/tempconvert.asmx Content-Type: text/xml; charset=utf-8 SOAPAction: "http://tempuri.org/CelsiusToFahrenheit" 30 ``` -------------------------------- ### Get Subscriptions (Explicit Cloud Selection) Source: https://github.com/huachao/vscode-restclient/wiki/Azure-Active-Directory-Authentication-Samples This sample shows how to explicitly select an Azure cloud for authentication using a specific identifier. ```APIDOC ## GET https://management.usgovcloudapi.net/subscriptions ### Description Retrieves subscriptions by explicitly selecting the Azure cloud using a specific identifier (e.g., 'us' for US Government). ### Method GET ### Endpoint https://management.usgovcloudapi.net/subscriptions ### Query Parameters - **api-version** (string) - Required - Specifies the API version to use. ### Headers - **Authorization** (string) - Required - Bearer token for Azure AD authentication, specifying the cloud identifier. ### Request Example ```http GET https://management.usgovcloudapi.net/subscriptions ?api-version=2017-08-01 Authorization: {{$aadToken us}} ``` ### Notes - Azure China may have specific limitations and might not work like other clouds. ``` -------------------------------- ### Send GET Request with Explicit Method and HTTP Version Source: https://context7.com/huachao/vscode-restclient/llms.txt Specify the HTTP method and version explicitly for GET requests. ```http ### GET with explicit method and HTTP version GET https://jsonplaceholder.typicode.com/posts HTTP/1.1 Accept: application/json ``` -------------------------------- ### REST Client Environment Variables Configuration Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Example of configuring environment variables within VS Code settings for the REST Client extension. ```json "rest-client.environmentVariables": { "$shared": { "version": "v1" }, "local": { "version": "v2", "host": "localhost", "secretKey": "DEVSECRET" }, "production": { "host": "example.com" ``` -------------------------------- ### VSCode REST Client Extension Settings Source: https://context7.com/huachao/vscode-restclient/llms.txt A comprehensive example of REST Client extension settings in .vscode/settings.json, covering network, proxy, response preview, and environment variables. ```jsonc // .vscode/settings.json — comprehensive example { // ── Network ───────────────────────────────────────────────────────── "rest-client.followredirect": true, "rest-client.timeoutinmilliseconds": 10000, // 0 = infinite "rest-client.defaultHeaders": { "User-Agent": "vscode-restclient", "Accept-Encoding": "gzip" }, // ── Proxy ──────────────────────────────────────────────────────────── // Uses VS Code's http.proxy setting; excludeHostsForProxy is REST-Client-specific "rest-client.excludeHostsForProxy": ["localhost", "127.0.0.1", "internal.corp"], // ── Response Preview ───────────────────────────────────────────────── "rest-client.previewOption": "full", // full | headers | body | exchange "rest-client.previewColumn": "beside", // beside | current "rest-client.previewResponseInUntitledDocument": false, "rest-client.previewResponsePanelTakeFocus": true, "rest-client.showResponseInDifferentTab": false, "rest-client.requestNameAsResponseTabTitle": true, // ── Large Response Handling ─────────────────────────────────────────── "rest-client.largeResponseBodySizeLimitInMB": 5, "rest-client.disableHighlightResponseBodyForLargeResponse": true, "rest-client.disableAddingHrefLinkForLargeResponse": true, // ── Cookies ────────────────────────────────────────────────────────── "rest-client.rememberCookiesForSubsequentRequests": true, // ── Response Body ───────────────────────────────────────────────────── "rest-client.decodeEscapedUnicodeCharacters": false, "rest-client.suppressResponseBodyContentTypeValidationWarning": false, "rest-client.mimeAndFileExtensionMapping": { "application/atom+xml": "xml" }, "rest-client.useContentDispositionFilename": true, // ── Editor ─────────────────────────────────────────────────────────── "rest-client.fontSize": 13, "rest-client.fontFamily": "Menlo, Monaco, Consolas, monospace", "rest-client.fontWeight": "normal", "rest-client.addRequestBodyLineIndentationAroundBrackets": true, "rest-client.formParamEncodingStrategy": "automatic", // automatic | never | always "rest-client.logLevel": "error", // error | warn | info | verbose "rest-client.enableSendRequestCodeLens": true, "rest-client.enableCustomVariableReferencesCodeLens": true, // ── Environments ───────────────────────────────────────────────────── "rest-client.environmentVariables": { "$shared": { "apiVersion": "v2" }, "dev": { "host": "localhost:3000", "token": "dev-token" }, "prod": { "host": "api.example.com", "token": "prod-token" } } } ``` -------------------------------- ### Digest Authentication Source: https://context7.com/huachao/vscode-restclient/llms.txt Example of using Digest Authentication. ```APIDOC ## Digest Auth ### Description Example request using Digest Authentication. ### Method GET ### Endpoint https://httpbin.org/digest-auth/auth/user/passwd ### Parameters #### Header Parameters - **Authorization** (string) - Required - Digest authentication credentials. ### Request Example ```http Authorization: Digest user passwd ``` ``` -------------------------------- ### Get Subscriptions (Implicit Cloud Selection) Source: https://github.com/huachao/vscode-restclient/wiki/Azure-Active-Directory-Authentication-Samples This sample demonstrates implicit cloud selection based on the REST endpoint's top-level domain (TLD). ```APIDOC ## GET https://management.microsoftazure.de/subscriptions ### Description Retrieves subscriptions by implicitly selecting the Azure cloud based on the TLD of the management endpoint. ### Method GET ### Endpoint https://management.microsoftazure.de/subscriptions ### Query Parameters - **api-version** (string) - Required - Specifies the API version to use. ### Headers - **Authorization** (string) - Required - Bearer token for Azure AD authentication. ### Request Example ```http GET https://management.microsoftazure.de/subscriptions ?api-version=2017-08-01 Authorization: {{$aadToken}} ``` ``` -------------------------------- ### Azure Active Directory (v1 — $aadToken) Source: https://context7.com/huachao/vscode-restclient/llms.txt Examples for Azure AD v1 authentication using the $aadToken variable. ```APIDOC ## Azure Active Directory (v1 — `$aadToken`) ### Description Examples for Azure AD v1 authentication using the `$aadToken` variable. ### Method GET ### Endpoint https://management.azure.com/subscriptions?api-version=2020-01-01 ### Parameters #### Header Parameters - **Authorization** (string) - Required - Azure AD v1 token. ### Request Example (Default Public Cloud) ```http Authorization: {{$aadToken}} ``` ### Request Example (Specific Tenant and Resource) ```http Authorization: {{$aadToken new public mytenant.onmicrosoft.com aud:https://graph.microsoft.com}} ``` ### Request Example (China Cloud) ```http Authorization: {{$aadToken new cn}} ``` ``` -------------------------------- ### AWS Cognito Authentication Source: https://context7.com/huachao/vscode-restclient/llms.txt Example of using AWS Cognito for authentication. ```APIDOC ## AWS Cognito ### Description Example request using AWS Cognito authentication. ### Method GET ### Endpoint https://api.example.com/protected ### Parameters #### Header Parameters - **Authorization** (string) - Required - AWS Cognito authentication string. ### Request Example ```http Authorization: COGNITO myuser@example.com MyPassword123 us-east-1 us-east-1_AbcDef123 4example23kmoim client-id-here ``` ``` -------------------------------- ### HTTP Request with Query Strings Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Demonstrates how to include query strings directly in the request line. For readability, parameters can be spread across multiple lines starting with '?' or '&'. ```http GET https://example.com/comments?page=2&pageSize=10 ``` ```http GET https://example.com/comments ?page=2 &pageSize=10 ``` -------------------------------- ### Digest Authentication Example Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Shows how to configure Digest Authentication for a request. The Authorization header should specify 'Digest' as the scheme, followed by the username and password. ```http GET https://httpbin.org/digest-auth/auth/user/passwd Authorization: Digest user passwd ``` -------------------------------- ### AWS Signature v4 Source: https://context7.com/huachao/vscode-restclient/llms.txt Examples for AWS Signature v4 authentication, including with and without session tokens. ```APIDOC ## AWS Signature v4 ### Description Examples for AWS Signature v4 authentication. ### Method GET ### Endpoint https://s3.amazonaws.com/my-bucket/my-object ### Parameters #### Header Parameters - **Authorization** (string) - Required - AWS Signature v4 authentication string. ### Request Example (Standard) ```http Authorization: AWS AKIAIOSFODNN7EXAMPLE wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY region:us-east-1 service:s3 ``` ### Request Example (With Session Token) ```http Authorization: AWS AKIAIOSFODNN7EXAMPLE wJalrXUtnFEMI region:us-east-1 service:sqs token:AQoXnyc4lcK4w== ``` ``` -------------------------------- ### Generate GUID Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Inserts a RFC 4122 version 4 UUID. ```bash {{$guid}} ``` -------------------------------- ### Get Subscriptions (Explicit Directory by Tenant ID) Source: https://github.com/huachao/vscode-restclient/wiki/Azure-Active-Directory-Authentication-Samples This sample demonstrates how to retrieve subscriptions by explicitly specifying the Azure AD tenant ID. ```APIDOC ## GET https://management.azure.com/subscriptions ### Description Retrieves a list of subscriptions by explicitly specifying the Azure AD tenant ID. ### Method GET ### Endpoint https://management.azure.com/subscriptions ### Query Parameters - **api-version** (string) - Required - Specifies the API version to use. ### Headers - **Authorization** (string) - Required - Bearer token for Azure AD authentication, specifying the tenant ID. ### Request Example ```http GET https://management.azure.com/subscriptions ?api-version=2017-08-01 Authorization: {{$aadToken 00000000-0000-0000-0000-000000000000}} ``` ``` -------------------------------- ### OIDC Access Token ($oidcAccessToken) Source: https://context7.com/huachao/vscode-restclient/llms.txt Examples for obtaining OIDC access tokens using the $oidcAccessToken variable for generic OIDC providers. ```APIDOC ## OIDC Access Token (`$oidcAccessToken`) ### Description Examples for obtaining OIDC access tokens using the `$oidcAccessToken` variable. ### Method GET ### Endpoint https://api.myapp.com/me ### Parameters #### Header Parameters - **Authorization** (string) - Required - Bearer token obtained via OIDC. ### Request Example (Generic OIDC Provider) ```http Authorization: Bearer {{$oidcAccessToken clientId:my-client-id authorizeEndpoint:https://auth.myapp.com/authorize tokenEndpoint:https://auth.myapp.com/token scopes:openid,profile,api:read}} ``` ### Request Example (Force New Token) ```http Authorization: Bearer {{$oidcAccessToken new clientId:admin-client authorizeEndpoint:https://auth.myapp.com/authorize tokenEndpoint:https://auth.myapp.com/token scopes:admin}} ``` ``` -------------------------------- ### Send Basic HTTP Request Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Type a URL directly to send a GET request. Ensure the file language mode is set to 'HTTP' or 'plaintext' for shortcuts to work. ```http https://example.com/comments/1 ``` -------------------------------- ### Get Subscriptions (Explicit Directory by Domain Name) Source: https://github.com/huachao/vscode-restclient/wiki/Azure-Active-Directory-Authentication-Samples This sample shows how to retrieve subscriptions by explicitly specifying the Azure AD domain name. ```APIDOC ## GET https://management.azure.com/subscriptions ### Description Retrieves a list of subscriptions by explicitly specifying the Azure AD domain name. ### Method GET ### Endpoint https://management.azure.com/subscriptions ### Query Parameters - **api-version** (string) - Required - Specifies the API version to use. ### Headers - **Authorization** (string) - Required - Bearer token for Azure AD authentication, specifying the domain name. ### Request Example ```http GET https://management.azure.com/subscriptions ?api-version=2017-08-01 Authorization: {{$aadToken contoso.com}} ``` ``` -------------------------------- ### Azure AD v2 / Microsoft Identity Platform ($aadV2Token) Source: https://context7.com/huachao/vscode-restclient/llms.txt Examples for Azure AD v2 authentication using the $aadV2Token variable, covering interactive and app-only flows. ```APIDOC ## Azure AD v2 / Microsoft Identity Platform (`$aadV2Token`) ### Description Examples for Azure AD v2 authentication using the `$aadV2Token` variable. ### Method GET ### Endpoint https://graph.microsoft.com/v1.0/me ### Parameters #### Header Parameters - **Authorization** (string) - Required - Azure AD v2 token. ### Request Example (Interactive User Sign-in) ```http Authorization: {{$aadV2Token scopes:User.Read}} ``` ### Request Example (App-only) ```http Authorization: {{$aadV2Token appOnly scopes:https://graph.microsoft.com/.default tenantId:mytenant.onmicrosoft.com clientId:00000000-0000-0000-0000-000000000000}} ``` ``` -------------------------------- ### Send POST Request with File Body (Relative Path) Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Specify a file path for the request body using '< '. Paths can be relative to the workspace root or the current HTTP file. This example uses a relative path. ```http POST https://example.com/comments HTTP/1.1 Content-Type: application/xml Authorization: token xxx < ./demo.xml ``` -------------------------------- ### Send POST Request with File Body (Absolute Path) Source: https://github.com/huachao/vscode-restclient/blob/master/README.md You can specify a file path to use as the request body by prefixing it with '< '. Whitespace in the file path is preserved. This example uses an absolute path. ```http POST https://example.com/comments HTTP/1.1 Content-Type: application/xml Authorization: token xxx < C:\Users\Default\Desktop\demo.xml ``` -------------------------------- ### AWS Signature v4 Example Source: https://context7.com/huachao/vscode-restclient/llms.txt Demonstrates AWS Signature Version 4 for authenticating requests to AWS services like S3. Ensure your AWS credentials and region/service are correctly specified. ```http GET https://s3.amazonaws.com/my-bucket/my-object HTTP/1.1 Authorization: AWS AKIAIOSFODNN7EXAMPLE wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY region:us-east-1 service:s3 ``` -------------------------------- ### System Dynamic Variables Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Utilize system dynamic variables for dynamic request parameters like GUIDs, random integers, timestamps, and environment variables. ```http GET https://httpbin.org/get?guid={{$guid}}×tamp={{$timestamp iso8601}} ### GET https://httpbin.org/get?env={{$processEnv NODE_ENV}} ### GET https://httpbin.org/get?dotenv={{$dotenv MY_VARIABLE}} ``` -------------------------------- ### Utilize System Variables for Dynamic Values Source: https://context7.com/huachao/vscode-restclient/llms.txt Use built-in system variables like `{{$guid}}`, `{{$timestamp}}`, `{{$datetime}}`, `{{$randomInt}}`, `{{$processEnv}}`, and `{{$dotenv}}` for dynamic request data. Offsets and formats can be specified. ```http POST https://api.example.com/events HTTP/1.1 Content-Type: application/json { "eventId": "{{$guid}}", "timestamp": "{{$timestamp}}", "scheduledFor": "{{$timestamp 2 d}}", "createdAt": "{{$datetime iso8601}}", "expiresAt": "{{$datetime iso8601 1 y}}", "localTime": "{{$localDatetime 'YYYY-MM-DD HH:mm:ss'}}", "rfcDate": "{{$datetime rfc1123}}", "randomScore": "{{$randomInt 1 100}}", "apiKey": "{{$processEnv API_SECRET_KEY}}", "dbPassword": "{{$dotenv DB_PASSWORD}}", "envKey": "{{$processEnv %secretKeyVarName}}" } ``` -------------------------------- ### Get Azure AD Token for Explicit Directory (Tenant ID) Source: https://github.com/huachao/vscode-restclient/wiki/Azure-Active-Directory-Authentication-Samples Specify a particular Azure AD directory for authentication by providing its Tenant ID. ```http GET https://management.azure.com/subscriptions ?api-version=2017-08-01 Authorization: {{$aadToken 00000000-0000-0000-0000-000000000000}} ``` -------------------------------- ### Get Azure AD Token Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Use to obtain an Azure Active Directory token. Specify options like re-authentication, cloud environment, domain/tenant ID, and audience. ```bash {{$aadToken [new] [public|cn|de|us|ppe] [] [aud:]}} ``` -------------------------------- ### Format Query String Over Multiple Lines Source: https://context7.com/huachao/vscode-restclient/llms.txt Split long query strings across multiple lines for better readability. Each new line should start with '?' or '&'. ```http GET https://api.github.com/search/repositories ?q=vscode+extension &sort=stars &order=desc &per_page=10 Accept: application/json ``` -------------------------------- ### Get Azure AD Token for Explicit Directory (Domain Name) Source: https://github.com/huachao/vscode-restclient/wiki/Azure-Active-Directory-Authentication-Samples Authenticate to a specific Azure AD directory by providing its domain name. ```http GET https://management.azure.com/subscriptions ?api-version=2017-08-01 Authorization: {{$aadToken contoso.com}} ``` -------------------------------- ### Azure AD v1 Token Request (China Cloud) Source: https://context7.com/huachao/vscode-restclient/llms.txt Example of obtaining an Azure AD v1 token for the China cloud environment. The 'cn' parameter specifies the cloud. ```http GET https://management.chinacloudapi.cn/subscriptions?api-version=2020-01-01 HTTP/1.1 Authorization: {{$aadToken new cn}} ``` -------------------------------- ### AWS Cognito Authentication Source: https://context7.com/huachao/vscode-restclient/llms.txt Example of authenticating with AWS Cognito using a specific format that includes username, password, region, and client ID. Ensure all parameters are correctly provided. ```http GET https://api.example.com/protected HTTP/1.1 Authorization: COGNITO myuser@example.com MyPassword123 us-east-1 us-east-1_AbcDef123 4example23kmoim client-id-here ``` -------------------------------- ### Send POST Request with XML Body Source: https://github.com/huachao/vscode-restclient/blob/master/README.md To send a request with a body, add a blank line after the headers. The content following the blank line is treated as the request body. This example shows sending an XML payload. ```http POST https://example.com/comments HTTP/1.1 Content-Type: application/xml Authorization: token xxx sample ``` -------------------------------- ### Get Azure AD V2 Token Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Use to obtain an Azure Active Directory token with v2 endpoint. Supports options for re-authentication, cloud, app-only flow, scopes, tenant ID, and client ID. ```bash {{$aadV2Token [new] [AzureCloud|AzureChinaCloud|AzureUSGovernment|ppe] [appOnly ][scopes:] [tenantid:] [clientid:]}} ``` -------------------------------- ### Get Azure AD Token for Default Directory Source: https://github.com/huachao/vscode-restclient/wiki/Azure-Active-Directory-Authentication-Samples Use this snippet to get an Azure AD token for the default directory associated with your account. The token cache is cleared on VS Code restart. ```http GET https://management.azure.com/subscriptions ?api-version=2017-08-01 Authorization: {{$aadToken}} ``` -------------------------------- ### Basic Authentication Source: https://context7.com/huachao/vscode-restclient/llms.txt Demonstrates three equivalent formats for Basic Authentication: raw username:password, pre-encoded Base64, and space-separated credentials. ```APIDOC ## Basic Auth ### Description Provides three equivalent formats for Basic Authentication. ### Method GET ### Endpoint https://httpbin.org/basic-auth/user/passwd ### Parameters #### Header Parameters - **Authorization** (string) - Required - Basic authentication token. ### Request Example (Format 1: raw) ```http Authorization: Basic user:passwd ``` ### Request Example (Format 2: pre-encoded) ```http Authorization: Basic dXNlcjpwYXNzd2Q= ``` ### Request Example (Format 3: space-separated) ```http Authorization: Basic user passwd ``` ``` -------------------------------- ### Basic Auth: Raw Username/Password Source: https://context7.com/huachao/vscode-restclient/llms.txt Demonstrates Basic Authentication using a raw 'username:password' string in the Authorization header. The extension normalizes this to Base64. ```http GET https://httpbin.org/basic-auth/user/passwd HTTP/1.1 Authorization: Basic user:passwd ``` -------------------------------- ### Define Prompt Variables for Dynamic Input Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Use '// @prompt variableName' or '# @prompt variableName "description"' to define variables that will prompt the user for input when the request is sent. Sensitive variables like 'password' are hidden. ```http @hostname = api.example.com @port = 8080 @host = {{hostname}}:{{port}} @contentType = application/json ### # @prompt username # @prompt refCode Your reference code display on webpage # @prompt otp Your one-time password in your mailbox POST https://{{host}}/verify-otp/{{refCode}} HTTP/1.1 Content-Type: {{contentType}} { "username": "{{username}}", "otp": "{{otp}}" } ``` -------------------------------- ### Environment Variables Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Use environment variables to manage different configurations for your requests. Supports environment switching. ```http @MyEnv = dev # @name {{MyEnv}} GET https://{{host}}/users # @name {{MyEnv}} GET https://{{host}}/posts ``` -------------------------------- ### Define and Reference Request Variables in HTTP File Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Demonstrates defining a base URL, a named login request, and then referencing its response headers and body in subsequent requests. Ensure named requests are triggered manually to resolve references. ```http @baseUrl = https://example.com/api # @name login POST {{baseUrl}}/api/login HTTP/1.1 Content-Type: application/x-www-form-urlencoded name=foo&password=bar ### @authToken = {{login.response.headers.X-AuthToken}} # @name createComment POST {{baseUrl}}/comments HTTP/1.1 Authorization: {{authToken}} Content-Type: application/json { "content": "fake content" } ### @commentId = {{createComment.response.body.$.id}} # @name getCreatedComment GET {{baseUrl}}/comments/{{commentId}} HTTP/1.1 Authorization: {{authToken}} ### # @name getReplies GET {{baseUrl}}/comments/{{commentId}}/replies HTTP/1.1 Accept: application/xml ### # @name getFirstReply GET {{baseUrl}}/comments/{{commentId}}/replies/{{getReplies.response.body.//reply[1]/@id}} ``` -------------------------------- ### Accessing Environment Variables Directly Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Demonstrates how to directly reference local machine environment variables using the `$processEnv` keyword. Ensure the environment variable is set on your local machine. ```http GET https://{{host}}/{{version}}/values/item1?user={{$processEnv USERNAME}} Authorization: {{$processEnv PRODSECRET}} ``` -------------------------------- ### Configure PEM SSL Client Certificates Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Set paths for public x509 certificate and private key in the VSCode settings for specific hostnames. Supports PEM format. ```json "rest-client.certificates": { "localhost:8081": { "cert": "/Users/demo/Certificates/client.crt", "key": "/Users/demo/Keys/client.key" }, "example.com": { "cert": "/Users/demo/Certificates/client.crt", "key": "/Users/demo/Keys/client.key" } } ``` -------------------------------- ### Prompt User for Input Variables Source: https://context7.com/huachao/vscode-restclient/llms.txt Use `# @prompt varName [description]` to interactively request values from the user when sending a request. Sensitive inputs like passwords are hidden. ```http @host = https://api.example.com # @prompt username Enter your username # @prompt password Your account password ``` -------------------------------- ### Configure PFX/PKCS12 SSL Client Certificates Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Set paths for PKCS #12 or PFX certificates and optional passphrase in VSCode settings. Supports PFX/PKCS12 format. ```json "rest-client.certificates": { "localhost:8081": { "pfx": "/Users/demo/Certificates/clientcert.p12", "passphrase": "123456" } } ``` -------------------------------- ### Import Swagger/OpenAPI - REST Client Source: https://context7.com/huachao/vscode-restclient/llms.txt Import API definitions from Swagger/OpenAPI files (.yaml, .yml, .json) via the command palette. This converts paths and operations into REST Client .http request blocks. ```plaintext // Via command palette: F1 → Rest Client: Import from file ``` -------------------------------- ### Configure SSL Client Certificates Source: https://context7.com/huachao/vscode-restclient/llms.txt Configuration for using SSL client certificates with the REST Client. Certificates are specified per-host in VS Code settings. ```jsonc // .vscode/settings.json { "rest-client.certificates": { "api.example.com": { "cert": "/Users/me/certs/client.crt", "key": "/Users/me/certs/client.key" }, "localhost:8443": { "pfx": "/Users/me/certs/client.p12", "passphrase": "mysecret" } } } ``` -------------------------------- ### Per-request Metadata Source: https://context7.com/huachao/vscode-restclient/llms.txt Demonstrates how to set per-request metadata like name, notes, and redirect behavior using `# @key [value]` lines. ```APIDOC ## Request Metadata / Per-request Settings ### Description Sets per-request metadata using `# @key [value]` lines immediately before the request URL. ### Request Example (`@name`, `@note`) ```http # @name getUser # @note GET https://api.example.com/users/42 HTTP/1.1 Authorization: Bearer {{token}} ``` ### Request Example (`@no-redirect`) ```http # @no-redirect GET https://short.example.com/abc HTTP/1.1 ``` ### Request Example (`@no-cookie-jar`) ```http # @no-cookie-jar POST https://api.example.com/auth/login HTTP/1.1 Content-Type: application/json {"username": "admin", "password": "{{$processEnv ADMIN_PASS}}"} ``` ``` -------------------------------- ### Upload Raw Binary File Source: https://context7.com/huachao/vscode-restclient/llms.txt Stream a raw binary file as the request body using '< ./path/to/file'. Set Content-Type appropriately. ```http ### Upload raw binary file POST https://httpbin.org/post HTTP/1.1 Content-Type: application/octet-stream < ./data/payload.bin ``` -------------------------------- ### Get OIDC Access Token Source: https://github.com/huachao/vscode-restclient/blob/master/README.md Use to obtain an OIDC Identity Server token. Options include re-authentication, client ID, callback port, authorization and token endpoints, scopes, and audience. ```bash {{$oidcAccessToken [new] [] [] [authorizeEndpoint: