Skip to content

Instantly share code, notes, and snippets.

@Kevin7020
Created July 12, 2020 23:32
Show Gist options
  • Select an option

  • Save Kevin7020/640b34853e0c12a8229e3ff079341eb7 to your computer and use it in GitHub Desktop.

Select an option

Save Kevin7020/640b34853e0c12a8229e3ff079341eb7 to your computer and use it in GitHub Desktop.
POST request using powershell and a dynamic JSON body to a discord webhook
# Base post example taken from here https://www.jokecamp.com/blog/invoke-restmethod-powershell-examples/
function Send-DiscordNotif($text, $webhook) {
$json = @{
content=$text
}
$body = $json | ConvertTo-Json
$response = Invoke-RestMethod -Method Post -Uri $webhook -Body $body -ContentType 'application/json'
$response
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment