I'm having trouble converting the syntax in the documentation for statuspage to work with invoke-restmethod as a powershell novice. I simply want to execute https://developer.statuspage.io/#operation/postPagesPageIdSubscribersReactivate from powershell for all subscribers.
So far I have:
$params = @{
Headers = @{"Authorization" = $ApiKey
'Content-Type'='application/json'
'subscribers' = 'all'}
Method = "Post"
subscribers = "all"
Uri = "https://api.statuspage.io/v1/pages/$PageId/subscribers/reactivate"
}
$res = Invoke-RestMethod @params
Write-LogFile $res
But that doesn't give me any meaningful output.
I do get meaningful output with simple GET commands.
$params2 = @{
Headers = @{"Authorization" = $ApiKey}
Method = "Get"
Uri = "https://api.statuspage.io/v1/pages/$PageId/subscribers"
}
$subscribers2 = Invoke-RestMethod @params2
$subscribers2Count = $subscribers2.count
Write-LogFile "subscribers='$subscribers2Count'"
FOReach ($sub2 in $subscribers2) {
Write-LogFile "s2: '$sub2'"
}
Hello Skyler,
This is Jesse from the Statuspage support team. Welcome to the community, and thanks for the question about getting no meaningful output for reactivating quarantined users. Looking at the link you sent of our API endpoint, it seems this does not return anything when the Status code 201. It only throws a message when there is an error for this endpoint. Since it simply reactivates quarantined users, it does not seem to give an output other than doing the reactivation. I can confirm this when I try it on Postman.
If you did want to see all the subscribers that were in quarantine before you take them out, you can run the https://developer.statuspage.io/#operation/getPagesPageIdSubscribers endpoint and use the "state" parameter to set it to quarantined only. It looks like you did something similar in your GET request.
As far as syntax is concerned, you seem to have it right. When you run this, does it take all the quarantined subscribers and reactivate them as expected?
Regards,
Jesse
Hi Jesse, thanks for responding and verifying my syntax. I'm actually debugging a script that's supposed to resubscribe users, but there are users that aren't getting notifications, and I'm trying to figure out why. I found that when I got a list of quarantined users with "unsubscribed", then I'd get a list of quarantined accounts that all match with the email I want to subscribe, and when I get a list of subscribers they aren't included. I'm thinking that the list of quarantined subscribers has something to do with this problem. I was hoping reactivate would help, but it doesn't seem to be reactivating.
Code sample in question:
--------------------------------------
$params2 = @{
Headers = @{"Authorization" = $ApiKey}
Method = "Get"
Uri = "https://api.statuspage.io/v1/pages/$PageId/subscribers"
}
$subscribers2 = Invoke-RestMethod @params2
$subscribers2Count = $subscribers2.count
Write-LogFile "subscribers='$subscribers2Count'"
FOReach ($sub2 in $subscribers2) {
Write-LogFile "s2: '$sub2'"
}
//note that this gives list of subscribers, but the email in question that I call with is not on that list
$params4 = @{
Headers = @{"Authorization" = $ApiKey
'Content-Type'='application/json'
'subscribers' = 'all'}
Method = "Post"
subscribers = "all"
Uri = "https://api.statuspage.io/v1/pages/$PageId/subscribers/reactivate"
}
$res = Invoke-RestMethod @params4
Write-LogFile $res
//now get list of quarantined subscribers
$params3 = @{
Headers = @{"Authorization" = $ApiKey}
Method = "Get"
Uri = "https://api.statuspage.io/v1/pages/$PageId/subscribers/unsubscribed"
}
$subscribers3 = Invoke-RestMethod @params3
$subscribers3Count = $subscribers3.count
Write-LogFile "subscribers3='$subscribers3Count'"
FOReach ($sub3 in $subscribers3) {
Write-LogFile "s3: '$sub3'"
}
//this gets me a list of 100 unsubbed subscribers that all have the same email that I'm trying to subscribe, even after running reactivate all
-------------------------------------
But after this code, I do a call to get a subscriber with that email in question, which I don't understand. I'm thinking the unsubbed subscribers with the same email have something to do with it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Skyler,
I wanted to point out a few things that might help your end goal.
Quarantined Subscribers: These subscribers were blocked from receiving emails because they marked Statuspage as spam or messages were dropped. Using the reactivation API endpoint takes these quarantined subscribers and moves them back to being active. However, if the same issue persists, they will end up in quarantine again. Reactivating subscribers does not work on unsubscribed subscribers.
Reactivating unsubscribed subscribers:
1. Get a list of unsubscribed subscribers
2. Gather the list of email addresses from that list
3. Create a new subscriber for each email address.
Why you are getting 100 unsubbed subscribers all with the same email: I am not 100% sure, but we treat each subscription ID as a different subscriber, so if that email was used multiple times for unsubscribing and resubscribing, you might be getting that same email with different IDs. You may need to use pagination to get the other pages, as the API endpoint only gets 100 results max per call.
Hopefully, that helps you get in the right direction. If you still run into issues, it might be worth opening a support ticket with us at support.atlassian.com so we can troubleshoot this specifically with your page in mind.
Regards,
Jesse
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.