Skip to content

Instantly share code, notes, and snippets.

@AvgustPol
Last active August 19, 2020 09:04
Show Gist options
  • Save AvgustPol/6f54d80e4701f35de20f50bab85e308d to your computer and use it in GitHub Desktop.
Save AvgustPol/6f54d80e4701f35de20f50bab85e308d to your computer and use it in GitHub Desktop.
HTTP POST Powershell send JSON
$ExampleVariable1 = "..your data here..";
$ExampleVariable2 = "..your data here..";
$ExampleVariableN = "..your data here..";
$url = 'https://..your url here..';
$requestBody = @{
ExampleVariable1 = '$(ExampleVariable1)'
ExampleVariable2 = '$(ExampleVariable2)'
ExampleVariableN = '$(ExampleVariableN)'
}
$json = $requestBody | ConvertTo-Json
#POST
Invoke-WebRequest -UseBasicParsing $postToDashboardUrl -ContentType "application/json" -Method POST -Body $json
#GET
Invoke-WebRequest -UseBasicParsing $postToDashboardUrl -ContentType "application/json" -Method GET -Body $json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment