Reply

POST command stopped working

Techie
Posts: 7
1664     0

Hi all,

 

$pwd = ConvertTo-SecureString "XX" -AsPlainText -Force
$creds = New-Object Management.Automation.PSCredential ('XX', $pwd)

$uri = "https://XX.XX.XX.XX/wapi/v2.4/network/ZG5zLm5ldHdvcmskMTcyLjE2LjIxNC4wLzI0LzA:XXX.XX.XXX.X/24/default?_function=next_available_ip"

$host_details = @{
num=1
}
#convert to json format
$body = $host_details | ConvertTo-Json
Write-Host $body
$response2 = Invoke-WebRequest -Uri $uri -Method POST -Credential $creds -ContentType 'application/json' -Body $body -UseBasicParsing
Write-Host $response2

 

I am using the above code, it was working fine earlier then it suddenly stopped working and gave an error  

Invoke-WebRequest : The remote server returned an error: (400) Bad Request.
At C:\XXXXX\pl code.ps1:45 char:14
+ ... response2 = Invoke-WebRequest -Uri $uri -Method POST -Credential $cre ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

I have even tried 

$url1 = "https://XX.XX.XX.XX/wapi/v2.4/fixedaddress"

same error [it was working earlier].

But all my "GET" commands are working only issue with my "POST" commands.

 

Thanks 

 

Re: POST command stopped working

Techie
Posts: 7
1665     0

The above user is subnet user with restricted permission with which it was working, then a admin user was created and everything stopped working.

So can creation of new user cause this issue.

 

Thanks in advance.

Showing results for 
Search instead for 
Did you mean: 

Recommended for You