Invoke-RestMethod error code 2100 returned


I am trying to pull list of users using the Rest API. I had this working last in April, on a different laptop. I have changed laptops and haven’t tried getting this script running since then. It work successfully back in April on the other system.

I run the following, which is just the beginning of the entire script.
$APIKey=“Token token=”
$URI0 = “
Invoke-RestMethod -Method Get -Uri $URI0 -Headers @{“Authorization”=$APIKey}

I started getting this error:
Invoke-RestMethod : {“error”:{“message”:“Not Found”,“code”:2100}}

I then started removing parts of the url and I finally got some sort of response just using “

Once I add /users onto the end, it fails again. I have no idea what changed from April till now. It doesn’t look like its something with the new system I am on.

Any help is appreciated! I am new to API’s.

Hi Michael,

Do you also have an Accept header in your request?
Accept: application/vnd.pagerduty+json;version=2

I do not have that in there. I have tried adding it in there, but I am not sure how you would using powershell.

As I said, it was working before I got my new laptop. I don’t know what would have changed on my end, it looks like the url is invalid when I run it. This is what I based my script on initially, and that got things working.

Hi Michael,

I was able to run the Invoke-RestMethod module in Microsoft PowerShell. I am pasting the syntax I used in my test to fetch the user records. I hope it can come in use for you too.

Note: You will have to enter an API key from your account in the $apiKey variable to make it work for your account. I’ve redacted mine for obvious reasons.

$apiKey = "Token token=redacted"
$URI0 = ""
$URI1 = ""
$URI2 = ""

Invoke-RestMethod -Method Get -Uri $URI0 -Header @{ "Authorization" = $apiKey; "Accept" = "application/vnd.pagerduty+json;version=2”}

Kind regards,

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.