Invoke-Webrequest gets 401 on POST but not on GET with Basic Auth
问题 I have a dev site with Basic Auth enabled. I am get to GET a page using the following to add basic auth to the headers: $creds = "$($BASIC_AUTH_USER):$($BASIC_AUTH_PASS)" $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($creds)) $basicAuthValue = "Basic $encodedCreds" $headers = @{ Authorization = $basicAuthValue } $login = Invoke-WebRequest $url -SessionVariable session -UseBasicParsing -Headers $headers But I am unable to post to the same URL: $fields