When using PowerShell's Invoke-RestMethod
to a service that uses Windows Authentication, I'm getting a "401.2 Not Authorized" Exception, but I've confirmed via
$currentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
that I'm using the expected user. I've verified that user is allowed in my service's web.config. Here's my actual invocation:
Invoke-RestService -Method "POST" -Uri $serviceApiUri -Body (ConvertTo-Json $body) -UseDefaultCredentials -ContentType "application/json"
Anyone else have issues with PowerShell's Invoke-RestMethod with Windows Authentication? How can I fix this?