Last active
September 24, 2019 06:05
-
-
Save Stephanevg/0d40bdea736a46e65e07a855cb5f2779 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-module Polaris -force | |
# Using a script block | |
New-PolarisPostRoute -Path "/Pcc" -ScriptBlock { | |
$json = $Request.Body | |
$comp = $json.computerName | |
$FileName = $Json.FileName | |
$return = $comp + $FileName | |
$response.Send($return) | |
} -Force | |
New-PolarisGetRoute -Path '/get' -Scriptblock { | |
$Response.send('plop') | |
} | |
# Using a script path | |
Start-Polaris -UseJsonBodyParserMiddleware -Verbose | |
<# | |
Code call for testing: | |
$Data = @{ | |
FileName = 'plop.ps1' | |
ComputerName = $Env:computerNAme | |
PackageName = 'plop' | |
RunTime = '1.4.5' | |
} | |
$JsonBody = $Data | ConvertTo-Json | |
#both ways here freen | |
Invoke-RestMethod -Method post -Uri http://localhost:8080/Pcc -Body $Jsonbody -ContentType 'application/json' -verbose |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Okay - Try this!
Now, your client request