Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Post authenticated message to Azure DevOps Incoming Webhook
# URL to the Azure DevOps incoming webhook endpoint. Expected format is
# Shared secret used to sign the JSON payload. Must be the same value supplied during
# the creation of the Incoming Webhook service connection
# HTTP header name to send the hash signature. When omitted, defaults to "X-Hub-Signature"
$HeaderName = 'X-Hub-Signature',
# JSON payload to send to the Azure DevOps web hook
$hmacSha = New-Object System.Security.Cryptography.HMACSHA1 -Property @{
Key = [Text.Encoding]::ASCII.GetBytes($secret)
$hashBytes = $hmacSha.ComputeHash([Text.Encoding]::UTF8.GetBytes($body))
$signature = ''
$hashBytes | ForEach-Object { $signature += $_.ToString('x2')}
$headers = @{
$headerName = "sha1=$signature"
Invoke-WebRequest -Uri $Url -Body $Body -Method Post -ContentType 'application/json' -Headers $headers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment