einast / PS_M365_scripts

Public repository of scripts
8 stars 10 forks source link

Invoke-RestMethod throwing forbidden error 403 #8

Closed FlyingCowInTheAir closed 2 years ago

FlyingCowInTheAir commented 2 years ago

We are getting Invoke-RestMethod throwing forbidden error 403, any suggestions ?

einast commented 2 years ago

Hi, 403 points to a permission issue. Can you check that everything is set up correctly, and then run the script again? I'm not sure where you run the script from, but I mainly use Azure Automation. If that's the case, some pointers are found here: https://docs.microsoft.com/en-us/answers/questions/881179/403-error-in-invoke-webrequest-azure-automation-ac.html (Invoke-WebRequest, but the troubleshooting steps outlined a bit down on the page are the same).

FlyingCowInTheAir commented 2 years ago

Hi! Thanks for your quick reply ! I run the script local and in Azure Automation with the same result, and I registrated the app as discribed in the link. Not much room for errors :) I look at the link you posted. Thanks.

FlyingCowInTheAir commented 2 years ago

it seems that you need ServiceHealth.Read.All and ServiceMessage.Read.All as well on the API acces

einast commented 2 years ago

Great, probably some changes since I originally wrote the script and blog posts. I haven't really used the scripts in a while, as my customer assignments have been focusing on other areas. I will try to get some time to update the posts to reflect the permission changes. Thanks!