Introducing SOC Insights for BloxOne Threat Defense: Boost your SOC efficiency with AI-driven insights to eliminate manual work and accelerate investigation and response times. Read the blog announcement here.

API Examples


POST command stopped working

Posts: 7
1161     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 = @{
#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.




Re: POST command stopped working

Posts: 7
1162     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