Powershell Delete Invoke-RestMethod - Response status code does not indicate success: 302 ()

Viewed 38

When I try to execute Invoke-RestMethod using the method Delete error coming as Response status code does not indicate success: 302 ().

But when the method change to Get, the Response is successful.

Power Shell Script

$iniURL = "http://reporting-rest-automation.xxx.com/reporting/rest_v2/resources/S_Reports/Isvarat/"
$username = "admin"
$password = "admin"
$method = "DELETE"
$credPair = "$($username):$($password)"
$encodedCredentials = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($credPair))
$headers = @{ Authorization = "Basic $encodedCredentials" }
Invoke-RestMethod -uri $iniURL -Method $method  -Headers $headers -MaximumRedirection 0 -ErrorAction Stop

Response

Invoke-RestMethod -uri $iniURL -Method $method  -Headers $headers -Ma …
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Response status code does not indicate success: 302 (Found).

What could be the problem?

0 Answers
Related