I am trying to convert curl to powershell with Invoke-RestMethod for onesignal push
the script that is used for onesignal:
curl --include \
--request POST \
--header "Content-Type: application/json; charset=utf-8" \
--header "Authorization: Basic YOUR_REST_API_KEY" \
--data-binary "{\"app_id\": \"YOUR_APP_ID\",
\"contents\": {\"en\": \"English Message\"},
\"included_segments\": [\"Subscribed Users\"]}" \
https://onesignal.com/api/v1/notifications
I have tried with following example which I was using for pushover but without success.
$uri = "https://onesignal.com/api/v1/notifications"
$parameters = @{
app_id = 'YOUR_APP_ID'
contents = "en: English Message"
included_segments = 'Subscribed Users'
data = 'foo:bar'
}
$parameters | Invoke-RestMethod -Uri $uri -Method Post
I have used this powershell script for pushover which worked fine, but now I want to move to onesignal and I have problems with where/how to put rest api key inside with already using app_id to push messages forward to users.
The code is snatched from: https://documentation.onesignal.com/v5.0/reference#section-example-code-create-notification
I hope that someone can assist me with this problem.
Regards