Pushover Webhook mit Powershell
Hallo liebes Forum,
ich möchte per Powershell einen Webhook an meinen Pushover-Account senden.
Ich habe die Pushover API FAQ gelesen, werde daraus aber nicht schlau.
Mein Script sieht wie folgt aus:
Fehler kommt folgender:
Kann hier jemand helfen?
Vielen Dank
ich möchte per Powershell einen Webhook an meinen Pushover-Account senden.
Ich habe die Pushover API FAQ gelesen, werde daraus aber nicht schlau.
Mein Script sieht wie folgt aus:
$url = "https://api.pushover.net/1/messages.json"
$headers = @{
"Content-Type" = "application/x-www-form-urlencoded"
}
$body = @{
"token" = "mein_token"
"user" = "mein_userkey"
"device" = "droid"
"title" = "Testmsg"
"message" = "Tesmsg"
} | ConvertTo-Json -Depth 3
Invoke-RestMethod -Uri $url -Method POST -Headers $headers -Body $body
Der Remoteserver hat einen Fehler zurückgegeben: (400) Ungültige Anforderung.
Kann hier jemand helfen?
Vielen Dank
Please also mark the comments that contributed to the solution of the article
Content-Key: 6460841547
Url: https://administrator.de/contentid/6460841547
Printed on: May 2, 2024 at 04:05 o'clock
2 Comments
Latest comment
Naja du sendest "Form encoded" als Content-Type im Header, konvertierst den Body aber nach JSON das passt eben nicht zusammen 😉, du musst dich schon entscheiden, entweder JSON oder form encoded.
Also
Oder
Cheers briggs
Also
$url = "https://api.pushover.net/1/messages.json"
$body = @{
"token" = "mein_token"
"user" = "mein_userkey"
"device" = "droid"
"title" = "Testmsg"
"message" = "Tesmsg"
}
Invoke-RestMethod -Uri $url -Method POST -ContentType 'application/x-www-form-urlencoded' -Body $body
$url = "https://api.pushover.net/1/messages.json"
$body = @{
"token" = "mein_token"
"user" = "mein_userkey"
"device" = "droid"
"title" = "Testmsg"
"message" = "Tesmsg"
} | convertto-json
Invoke-RestMethod -Uri $url -Method POST -ContentType 'application/json' -Body $body
Cheers briggs