So I am attempting to mess around with Powershell and REST but seem to be stuck on the most simplest of tasks. Every time I run the code below the result is always:
Invoke-RestMethod :
401 - Unauthorized: Access is denied due to invalid credentials.
Server Error
401 - Unauthorized: Access is denied due to invalid credentials.
You do not have permission to view this directory or page using the credentials that you supplied.
I don’t understand why. I can take the url and go to it in a browser, enter the same creds (not what is shown below) and it works. Works in Excel too. Just can’t get Powershell to connect. Any suggestions?
Code:
That’s misspelled but it shouldn’t matter. This works for me right out of the box, there is one thing where you need to enable some special permissions in powershell for this to execute right however it should have prompted you about that.
I do not. I have also tried multiple different users. I am perplexed. When I run it the first time, I see it in fiddler as result 200 and powershell says 401. Every time I run it again, no activity appears in Fiddler. I have to close powershell and reopen and rerun to get another entry in Fiddler. Not confident we are seeing what we should in Fiddler.
My colleague also tried on his system and it gets the same results.