Skip to content

Dot Http Files

Heath Brown edited this page Jun 15, 2024 · 1 revision

.http files

IDEs sometimes will support .http type files, such as, VSCode. Then with an extension these files can be read and executed via a REST client or http client.

If using Visual Studio Code, the extension is called Rest Client .

File Format

POST https://example.com/comments HTTP/1.1
content-type: application/json

{
    "name": "sample",
    "time": "Wed, 21 Oct 2015 18:27:50 GMT"
}

Multiple Requests in File

POST https://example.com/comments HTTP/1.1
content-type: application/json

{
    "name": "sample",
    "time": "Wed, 21 Oct 2015 18:27:50 GMT"
}

###

POST https://example.com/comments HTTP/1.1
content-type: application/json

{
    "name": "sample",
    "time": "Wed, 21 Oct 2015 18:27:50 GMT"
}

Multiple Requests in File

POST https://example.com/comments HTTP/1.1
content-type: application/json
Authorization: {{$token}}

{
    "name": "sample",
    "time": "Wed, 21 Oct 2015 18:27:50 GMT"
}

###

POST https://example.com/comments HTTP/1.1
content-type: application/json
Authorization: {{$token}}

{
    "name": "sample",
    "time": "Wed, 21 Oct 2015 18:27:50 GMT"
}

Environment Variables

"rest-client.environmentVariables": { "$shared": { "version": "v1", "prodToken": "foo", "nonProdToken": "bar" }, "local": { "version": "v2", "host": "localhost", "token": "{{$shared nonProdToken}}", "secretKey": "devSecret" }, "production": { "host": "example.com", "token": "{{$shared prodToken}}", "secretKey" : "prodSecret" } }

References

Clone this wiki locally