SimpleRequest is inspired by the HTTP Client in WebStrom, allow you to
- Compose an HTTP request by using general syntax
- Use variables to parametrize elements
- Intergate with Pester
Running this PowerShell command
Install-Module -Name SimpleRequest
METHOD Request-URI
Header-field: Header-value
Request-Body
Compose HTTP request as bellow:
Invoke-SimpleRequest -Syntax $Syntax [-Context $ContextData]
GET https://httpbin.org/ip
Content-Type: application/json
POST https://httpbin.org/post
Content-Type: application/json
{
"id": 1,
"value": "the-value"
}
When composing an HTTP request, you can parametrize its elements by using variables. To provide the variable inside the request, enclose it in double curly braces as {{variable}}
.
$Data = @{
"TokenUrl" = 111
"ClientSecret" = "222"
"ClientId" = "333"
"AuthResource" = "444"
"Username" = "User1"
"Password" = "Password"
"Id" = 99
"Price" = 0.99
"Value" = "Content"
}
$Sample = '
POST https://httpbin.org/post?id={{Id}}
Content-Type: application/json
Authorization: Bearer {{QIBToken}}
{
"id": {{Id}},
"value": "{{Value}}"
}'
$Response = Invoke-SimpleRequest -Syntax $Sample -Context $Data
Compose several requests in a single syntax, separate by ###
GET https://httpbin.org/ip
###
GET https://httpbin.org/anything
For example, you have a sample.sr
contains below syntax:
POST https://httpbin.org/anything
Authorization: AuthToken
x-custom-header: CustomHeader
{
"id": 1,
"value": "Value"
}
Then you can invoke it like this
Invoke-SimpleRequest -Path .\sample.sr
- Support compose requests from single file
- Support empty header field value
- Support headers with same field name, only the last one will be sent, values should be defined as a comma-separated list
- Predefined dynamic variables
- Compose several requests in a single syntax, separate by
###
- Break long requests into several lines
- Support multipart/form-data content type
- Export response to file