Converted PowerShell code to use Splatting, and newer PS7 parameters (where available)

pull/697/head
Nathan 2023-04-05 20:13:23 +01:00 committed by GitHub
parent e1339ccde7
commit c63ca95867
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 319 additions and 180 deletions

View File

@ -38,7 +38,12 @@ Here's an example showing how to publish a simple message using a POST request:
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
Invoke-RestMethod -Method 'Post' -Uri https://ntfy.sh/mytopic -Body "Backup successful" -UseBasicParsing $Request = @{
Method = "POST"
URI = "https://ntfy.sh/mytopic"
Body = "Backup successful"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -124,12 +129,17 @@ a [title](#message-title), and [tag messages](#tags-emojis) 🥳 🎉. Here's an
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.sh/phil_alerts" $Request = @{
$headers = @{ Title="Unauthorized access detected" Method = "POST"
Priority="urgent" URI = "https://ntfy.sh/phil_alerts"
Tags="warning,skull" } Headers = @{
$body = "Remote access to phils-laptop detected. Act right away." Title = "Unauthorized access detected"
Invoke-RestMethod -Method 'Post' -Uri $uri -Headers $headers -Body $body -UseBasicParsing Priority = "urgent"
Tags = "warning,skull"
}
Body = "Remote access to phils-laptop detected. Act right away."
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -242,18 +252,21 @@ an [external image attachment](#attach-file-from-a-url) and [email publishing](#
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.sh/mydoorbell" $Request = @{
$headers = @{ Click="https://home.nest.com/" Method = "POST"
Attach="https://nest.com/view/yAxkasd.jpg" URI = "https://ntfy.sh/mydoorbell"
Actions="http, Open door, https://api.nest.com/open/yAxkasd, clear=true" Headers = @{
Email="phil@example.com" } Click = "https://home.nest.com"
$body = @' Attach = "https://nest.com/view/yAxksd.jpg"
There's someone at the door. 🐶 Actions = "http, Open door, https://api.nest.com/open/yAxkasd, clear=true"
Email = "phil@example.com"
Please check if it's a good boy or a hooman. }
Doggies have been known to ring the doorbell. Body = "There's someone at the door. 🐶`n
'@ `n
Invoke-RestMethod -Method 'Post' -Uri $uri -Headers $headers -Body $body -UseBasicParsing Please check if it's a good boy or a hooman.`n
Doggies have been known to ring the doorbell.`n"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -342,10 +355,15 @@ you can set the `X-Title` header (or any of its aliases: `Title`, `ti`, or `t`).
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.sh/controversial" $Request = @{
$headers = @{ Title="Dogs are better than cats" } Method = "POST"
$body = "Oh my ..." URI = "https://ntfy.sh/controversial"
Invoke-RestMethod -Method 'Post' -Uri $uri -Headers $headers -Body $body -UseBasicParsing Headers = @{
Title = "Dogs are better than cats"
}
Body = "Oh my ..."
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -432,10 +450,14 @@ You can set the priority with the header `X-Priority` (or any of its aliases: `P
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.sh/phil_alerts" $Request = @{
$headers = @{ Priority="5" } URI = "https://ntfy.sh/phil_alerts"
$body = "An urgent message" Headers = @{
Invoke-RestMethod -Method 'Post' -Uri $uri -Headers $headers -Body $body -UseBasicParsing Priority = "5"
}
Body = "An urgent message"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -553,10 +575,15 @@ them with a comma, e.g. `tag1,tag2,tag3`.
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.sh/backups" $Request = @{
$headers = @{ Tags="warning,mailsrv13,daily-backup" } Method = "POST"
$body = "Backup of mailsrv13 failed" URI = "https://ntfy.sh/backups"
Invoke-RestMethod -Method 'Post' -Uri $uri -Headers $headers -Body $body -UseBasicParsing Headers = @{
Tags = "warning,mailsrv13,daily-backup"
}
Body = "Backup of mailsrv13 failed"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -645,10 +672,15 @@ to be delivered in 3 days, it'll remain in the cache for 3 days and 12 hours. Al
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.sh/hello" $Request = @{
$headers = @{ At="tomorrow, 10am" } Method = "POST"
$body = "Good morning" URI = "https://ntfy.sh/hello"
Invoke-RestMethod -Method 'Post' -Uri $uri -Headers $headers -Body $body -UseBasicParsing Headers = @{
At = "tomorrow, 10am"
}
Body = "Good morning"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -729,7 +761,7 @@ For instance, assuming your topic is `mywebhook`, you can simply call `/mywebhoo
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
Invoke-RestMethod -Method 'Get' -Uri "ntfy.sh/mywebhook/trigger" Invoke-RestMethod "ntfy.sh/mywebhook/trigger"
``` ```
=== "Python" === "Python"
@ -778,7 +810,7 @@ Here's an example with a custom message, tags and a priority:
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
Invoke-RestMethod -Method 'Get' -Uri "ntfy.sh/mywebhook/publish?message=Webhook+triggered&priority=high&tags=warning,skull" Invoke-RestMethod "ntfy.sh/mywebhook/publish?message=Webhook+triggered&priority=high&tags=warning,skull"
``` ```
=== "Python" === "Python"
@ -883,25 +915,29 @@ is the only required one:
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.sh" $Request = @{
$body = @{ Method = "POST"
topic = "mytopic" URI = "https://ntfy.sh"
title = "Low disk space alert" Body = @{
message = "Disk space is low at 5.1 GB" Topic = "mytopic"
priority = 4 Title = "Low disk space alert"
attach = "https://filesrv.lan/space.jpg" Message = "Disk space is low at 5.1 GB"
filename = "diskspace.jpg" Priority = 4
tags = @("warning", "cd") Attach = "https://filesrv.lan/space.jpg"
click = "https://homecamera.lan/xasds1h2xsSsa/" FileName = "diskspace.jpg"
actions = @( Tags = @("warning", "cd")
@{ Click = "https://homecamera.lan/xasds1h2xsSsa/"
action = "view" Actions = ConvertTo-JSON @(
label = "Admin panel" @{
url = "https://filesrv.lan/admin" Action = "view"
} Label = "Admin panel"
URL = "https://filesrv.lan/admin"
}
) )
} | ConvertTo-Json }
Invoke-RestMethod -Method 'Post' -Uri $uri -Body $body -ContentType "application/json" -UseBasicParsing ContentType = "application/json"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -1061,10 +1097,15 @@ As an example, here's how you can create the above notification using this forma
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.sh/myhome" $Request = @{
$headers = @{ Actions="view, Open portal, https://home.nest.com/, clear=true; http, Turn down, https://api.nest.com/, body='{\"temperature\": 65}'" } Method = "POST"
$body = "You left the house. Turn down the A/C?" URI = "https://ntfy.sh/myhome"
Invoke-RestMethod -Method 'Post' -Uri $uri -Headers $headers -Body $body -UseBasicParsing Headers = @{
Actions="view, Open portal, https://home.nest.com/, clear=true; http, Turn down, https://api.nest.com/, body='{\"temperature\": 65}'"
}
Body = "You left the house. Turn down the A/C?"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -1214,26 +1255,30 @@ Alternatively, the same actions can be defined as **JSON array**, if the notific
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.sh" $Request = @{
$body = @{ Method = "POST"
topic = "myhome" URI = "https://ntfy.sh"
message = "You left the house. Turn down the A/C?" Body = ConvertTo-JSON @{
actions = @( Topic = "myhome"
@{ Message = "You left the house. Turn down the A/C?"
action = "view" Actions = @(
label = "Open portal" @{
url = "https://home.nest.com/" Action = "view"
clear = $true Label = "Open portal"
}, URL = "https://home.nest.com/"
@{ Clear = $true
action = "http" },
label = "Turn down" @{
url = "https://api.nest.com/" Action = "http"
body = '{"temperature": 65}' Label = "Turn down"
} URL = "https://api.nest.com/"
Body = '{"temperature": 65}'
}
) )
} | ConvertTo-Json }
Invoke-RestMethod -Method 'Post' -Uri $uri -Body $body -ContentType "application/json" -UseBasicParsing ContentType = "application/json"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -1358,10 +1403,15 @@ Here's an example using the [`X-Actions` header](#using-a-header):
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.sh/myhome" $Request = @{
$headers = @{ Actions="view, Open Twitter, https://twitter.com/binwiederhier/status/1467633927951163392" } Method = "POST"
$body = "Somebody retweeted your tweet." URI = "https://ntfy.sh/myhome"
Invoke-RestMethod -Method 'Post' -Uri $uri -Headers $headers -Body $body -UseBasicParsing Headers = @{
Actions = "view, Open Twitter, https://twitter.com/binwiederhier/status/1467633927951163392"
}
Body = "Somebody retweeted your tweet."
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -1474,19 +1524,23 @@ And the same example using [JSON publishing](#publish-as-json):
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.sh" $Request = @{
$body = @{ Method = "POST"
topic = "myhome" URI = "https://ntfy.sh"
message = "Somebody retweeted your tweet." Body = ConvertTo-JSON @{
actions = @( Topic = "myhome"
@{ Message = "Somebody retweeted your tweet."
"action"="view" Actions = @(
"label"="Open Twitter" @{
"url"="https://twitter.com/binwiederhier/status/1467633927951163392" Action = "view"
} Label = "Open Twitter"
URL = "https://twitter.com/binwiederhier/status/1467633927951163392"
}
) )
} | ConvertTo-Json }
Invoke-RestMethod -Method 'Post' -Uri $uri -Body $body -ContentType "application/json" -UseBasicParsing ContentType = "application/json"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -1600,10 +1654,15 @@ Here's an example using the [`X-Actions` header](#using-a-header):
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.sh/wifey" $Request = @{
$headers = @{ Actions="broadcast, Take picture, extras.cmd=pic, extras.camera=front" } Method = "POST"
$body = "Your wife requested you send a picture of yourself." URI = "https://ntfy.sh/wifey"
Invoke-RestMethod -Method 'Post' -Uri $uri -Headers $headers -Body $body -UseBasicParsing Headers = @{
Actions = "broadcast, Take picture, extras.cmd=pic, extras.camera=front"
}
Body = "Your wife requested you send a picture of yourself."
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -1733,23 +1792,26 @@ And the same example using [JSON publishing](#publish-as-json):
``` powershell ``` powershell
# Powershell requires the 'Depth' argument to equal 3 here to expand 'Extras', # Powershell requires the 'Depth' argument to equal 3 here to expand 'Extras',
# otherwise it will read System.Collections.Hashtable in the returned JSON # otherwise it will read System.Collections.Hashtable in the returned JSON
$Request = @{
$uri = "https://ntfy.sh" Method = "POST"
$body = @{ URI = "https://ntfy.sh"
topic = "wifey" Body = @{
message = "Your wife requested you send a picture of yourself." Topic = "wifey"
actions = @( Message = "Your wife requested you send a picture of yourself."
@{ Actions = ConvertTo-Json -Depth 3 @(
action = "broadcast" @{
label = "Take picture" Action = "broadcast"
extras = @{ Label = "Take picture"
cmd ="pic" Extras = @{
camera = "front" CMD ="pic"
} Camera = "front"
} }
}
) )
} | ConvertTo-Json -Depth 3 }
Invoke-RestMethod -Method 'Post' -Uri $uri -Body $body -ContentType "application/json" -UseBasicParsing ContentType = "application/json"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -1861,10 +1923,15 @@ Here's an example using the [`X-Actions` header](#using-a-header):
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.sh/myhome" $Request = @{
$headers = @{ Actions="http, Close door, https://api.mygarage.lan/, method=PUT, headers.Authorization=Bearer zAzsx1sk.., body={\"action\": \"close\"}" } Method = "POST"
$body = "Garage door has been open for 15 minutes. Close it?" URI = "https://ntfy.sh/myhome"
Invoke-RestMethod -Method 'Post' -Uri $uri -Headers $headers -Body $body -UseBasicParsing Headers = @{
Actions="http, Close door, https://api.mygarage.lan/, method=PUT, headers.Authorization=Bearer zAzsx1sk.., body={\"action\": \"close\"}"
}
Body = "Garage door has been open for 15 minutes. Close it?"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -2005,24 +2072,28 @@ And the same example using [JSON publishing](#publish-as-json):
# Powershell requires the 'Depth' argument to equal 3 here to expand 'headers', # Powershell requires the 'Depth' argument to equal 3 here to expand 'headers',
# otherwise it will read System.Collections.Hashtable in the returned JSON # otherwise it will read System.Collections.Hashtable in the returned JSON
$uri = "https://ntfy.sh" $Request = @{
$body = @{ Method = "POST"
topic = "myhome" URI = "https://ntfy.sh"
message = "Garage door has been open for 15 minutes. Close it?" Body = @{
actions = @( Topic = "myhome"
@{ Message = "Garage door has been open for 15 minutes. Close it?"
action = "http" Actions = ConvertTo-Json -Depth 3 @(
label = "Close door" @{
url = "https://api.mygarage.lan/" Action = "http"
method = "PUT" Label = "Close door"
headers = @{ URL = "https://api.mygarage.lan/"
Authorization = "Bearer zAzsx1sk.." Method = "PUT"
} Headers = @{
body = '{"action": "close"}' Authorization = "Bearer zAzsx1sk.."
} }
Body = ConvertTo-JSON @{Action = "close"}
}
) )
} | ConvertTo-Json -Depth 3 }
Invoke-RestMethod -Method 'Post' -Uri $uri -Body $body -ContentType "application/json" -UseBasicParsing ContentType = "application/json"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -2149,10 +2220,13 @@ Here's an example that will open Reddit when the notification is clicked:
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.sh/reddit_alerts" $Request = @{
$headers = @{ Click="https://www.reddit.com/message/messages" } Method = "POST"
$body = "New messages on Reddit" URI = "https://ntfy.sh/reddit_alerts"
Invoke-RestMethod -Method 'Post' -Uri $uri -Headers $headers -Body $body -UseBasicParsing Headers = @{ Click="https://www.reddit.com/message/messages" }
Body = "New messages on Reddit"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -2321,9 +2395,12 @@ Here's an example showing how to attach an APK file:
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.sh/mydownloads" $Request = @{
$headers = @{ Attach="https://f-droid.org/F-Droid.apk" } Method = "POST"
Invoke-RestMethod -Method 'Post' -Uri $uri -Headers $headers -UseBasicParsing URI = "https://ntfy.sh/mydownloads"
Headers = @{ Attach="https://f-droid.org/F-Droid.apk" }
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -2414,12 +2491,17 @@ Here's an example showing how to include an icon:
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.sh/tvshows" $Request = @{
$headers = @{ Title"="Kodi: Resuming Playback" Method = "POST"
Tags="arrow_forward" URI = "https://ntfy.sh/tvshows"
Icon="https://styles.redditmedia.com/t5_32uhe/styles/communityIcon_xnt6chtnr2j21.png" } Headers = @{
$body = "The Wire, S01E01" Title = "Kodi: Resuming Playback"
Invoke-RestMethod -Method 'Post' -Uri $uri -Headers $headers -Body $body -UseBasicParsing Tags = "arrow_forward"
Icon = "https://styles.redditmedia.com/t5_32uhe/styles/communityIcon_xnt6chtnr2j21.png"
}
Body = "The Wire, S01E01"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -2525,13 +2607,18 @@ that, your IP address appears in the e-mail body. This is to prevent abuse.
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.sh/alerts" $Request = @{
$headers = @{ Title"="Low disk space alert" Method = "POST"
Priority="high" URI = "https://ntfy.sh/alerts"
Tags="warning,skull,backup-host,ssh-login") Headers = @{
Email="phil@example.com" } Title = "Low disk space alert"
$body = "Unknown login from 5.31.23.83 to backups.example.com" Priority = "high"
Invoke-RestMethod -Method 'Post' -Uri $uri -Body $body -UseBasicParsing Tags = "warning,skull,backup-host,ssh-login")
Email = "phil@example.com"
}
Body = "Unknown login from 5.31.23.83 to backups.example.com"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -2657,14 +2744,35 @@ Here's an example with a user `testuser` and password `fakepassword`:
http.DefaultClient.Do(req) http.DefaultClient.Do(req)
``` ```
=== "PowerShell" === "PowerShell 7+"
``` powershell ``` powershell
$uri = "https://ntfy.example.com/mysecrets" # Get the credentials from the user
$credentials = 'testuser:fakepassword' $Credential = Get-Credential testuser
$encodedCredentials = [convert]::ToBase64String([text.Encoding]::UTF8.GetBytes($credentials)) # Alternatively, create a PSCredential object with the password from scratch
$headers = @{Authorization="Basic $encodedCredentials"} $Credential = [PSCredential]::new("testuser", (ConvertTo-SecureString "password" -AsPlainText -Force))
$message = "Look ma, with auth"
Invoke-RestMethod -Uri $uri -Body $message -Headers $headers -Method "Post" -UseBasicParsing # Note that the Authentication parameter requires PowerShell 7 or later
$Request = @{
Method = "POST"
URI = "https://ntfy.example.com/mysecrets"
Authentication = "Basic"
Credential = $Credential
Body = "Look ma, with auth"
}
Invoke-RestMethod @Request
```
=== "PowerShell 5 and earlier"
# With PowerShell 5 or earlier, we need to create the base64 username:password string ourselves
$CredentialString = "$($Credential.Username):$($Credential.GetNetworkCredential().Password)"
$EncodedCredential = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($CredentialString))
$Request = @{
Method = "POST"
URI = "https://ntfy.example.com/mysecrets"
Headers = @{ Authorization = "Basic $EncodedCredential"}
Body = "Look ma, with auth"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -2761,12 +2869,28 @@ with the token `tk_AgQdq7mVBoFD37zQVN29RhuMzNIz2`:
http.DefaultClient.Do(req) http.DefaultClient.Do(req)
``` ```
=== "PowerShell" === "PowerShell 7+"
``` powershell ``` powershell
$uri = "https://ntfy.example.com/mysecrets" # With PowerShell 7 or greater, we can use the Authentication and Token parameters
$headers = @{Authorization="Bearer tk_AgQdq7mVBoFD37zQVN29RhuMzNIz2"} $Request = @{
$message = "Look ma, with auth" Method = "POST"
Invoke-RestMethod -Uri $uri -Body $message -Headers $headers -Method "Post" -UseBasicParsing URI = "https://ntfy.example.com/mysecrets"
Authorization = "Bearer"
Token = "tk_AgQdq7mVBoFD37zQVN29RhuMzNIz2"
Body = "Look ma, with auth"
}
Invoke-RestMethod @Request
```
=== "PowerShell 5 and earlier"
# In PowerShell 5 and below, we can only send the Bearer token as a string in the Headers
$Request = @{
Method = "POST"
URI = "https://ntfy.example.com/mysecrets"
Headers = @{ Authorization = "Bearer tk_AgQdq7mVBoFD37zQVN29RhuMzNIz2" }
Body = "Look ma, with auth"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -2841,10 +2965,16 @@ access token. This is primarily useful to make `curl` calls easier, e.g. `curl -
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.example.com/mysecrets" # Note that PSCredentials *must* have a username, so we fall back to placing the authorization in the Headers as with PowerShell 5
$headers = @{Authorization="Basic OnRrX0FnUWRxN21WQm9GRDM3elFWTjI5Umh1TXpOSXoy"} $Request = @{
$message = "Look ma, with auth" Method = "POST"
Invoke-RestMethod -Uri $uri -Body $message -Headers $headers -Method "Post" -UseBasicParsing URI = "https://ntfy.example.com/mysecrets"
Headers = @{
Authorization = "Basic OnRrX0FnUWRxN21WQm9GRDM3elFWTjI5Umh1TXpOSXoy"
}
Body = "Look ma, with auth"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -2913,9 +3043,12 @@ Here's an example using the `auth` query parameter:
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.example.com/mysecrets?auth=QmFzaWMgZEdWemRIVnpaWEk2Wm1GclpYQmhjM04zYjNKaw" $Request = @{
$message = "Look ma, with auth" Method = "POST"
Invoke-RestMethod -Uri $uri -Body $message -Method "Post" -UseBasicParsing URI = "https://ntfy.example.com/mysecrets?auth=QmFzaWMgZEdWemRIVnpaWEk2Wm1GclpYQmhjM04zYjNKaw"
Body = "Look ma, with auth"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -3012,10 +3145,13 @@ are still delivered to connected subscribers, but [`since=`](subscribe/api.md#fe
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.sh/mytopic" $Request = @{
$headers = @{ Cache="no" } Method = "POST"
$body = "This message won't be stored server-side" URI = "https://ntfy.sh/mytopic"
Invoke-RestMethod -Method 'Post' -Uri $uri -Body $body -Headers $headers -UseBasicParsing Headers = @{ Cache="no" }
Body = "This message won't be stored server-side"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"
@ -3092,10 +3228,13 @@ to `no`. This will instruct the server not to forward messages to Firebase.
=== "PowerShell" === "PowerShell"
``` powershell ``` powershell
$uri = "https://ntfy.sh/mytopic" $Request = @{
$headers = @{ Firebase="no" } Method = "POST"
$body = "This message won't be forwarded to FCM" URI = "https://ntfy.sh/mytopic"
Invoke-RestMethod -Method 'Post' -Uri $uri -Body $body -Headers $headers -UseBasicParsing Headers = @{ Firebase="no" }
Body = "This message won't be forwarded to FCM"
}
Invoke-RestMethod @Request
``` ```
=== "Python" === "Python"