Infoblox Exchange Cybersecurity Roadshow 2020 – Join us!
North America | Europe | Middle East/Africa | Asia-Pacific

API Examples

Reply
Highlighted

Update MSServer Options with REST API in Powershell

[ Edited ]
aleser
Not applicable
Posts: 4
559     0

Hello,

 

I want to update the options for msserver:dhcp and msserver:dns via powershell, for example login_name, login_password, synchronization_interval but it doesn't work, looks like I missed something in the options.

 

$msserver_options = @{
synchronization_interval="10"}
$body = $msserver_options | ConvertTo-Json


$uri_msdhcp = "$($ib_uri_base)/msserver:dhcp/ZG5zLm1zX3NlcnZlcl9kaGNwX3Byb3BlcnRpZXMkMA:10.0.0.1?_return_as_object=1"


Invoke-RestMethod -Uri $uri_msdhcp -Method PUT -WebSession $ib_session -ContentType 'application/json' -Body $body

Error Message

 

Invoke-RestMethod : Der Remoteserver hat einen Fehler zurückgegeben: (400) Ungültige Anforderung.
In Zeile:7 Zeichen:1
+ Invoke-RestMethod -Uri $uri_msdhcp -Method PUT -WebSession $ib_session -ContentT ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

 

 

the GET command works fine and give me the correct result, I also tryed to another PUT command to update the name of a fixed address which also works fine.

 

GET ms-dhcp

 

$uri_msdhcp = "$($ib_uri_base)/msserver:dhcp/ZG5zLm1zX3NlcnZlcl9kaGNwX3Byb3BlcnRpZXMkMA:10.0.0.1?_return_fields=synchronization_interval&_return_type=json"
Invoke-WebRequest -Uri $uri_msdhcp -Method Get -WebSession $ib_session

StatusCode : 200
StatusDescription : OK
Content : {"_ref": "msserver:dhcp/ZG5zLm1zX3NlcnZlcl9kaGNwX3Byb3BlcnRpZXMkMA:10.0.0.1", "synchronization_interval": 2}

 

thanks in advance

Andreas

Re: Update MSServer Options with REST API in Powershell

Adviser
Posts: 111
560     0

Hi,

 

An integer is expected for synchronization_interval. Could you please remove the quotes around 10 and try again?

 

Thanks and regards,

Krishna

Re: Update MSServer Options with REST API in Powershell

aleser
Not applicable
Posts: 4
560     0

Hi Krishna,

 

I tryed this already but get the same error message

 

$msserver_options = @{
synchronization_interval=10}
$body = $msserver_options | ConvertTo-Json

kind regards,

Andreas

 

Re: Update MSServer Options with REST API in Powershell

[ Edited ]
aleser
Not applicable
Posts: 4
560     0

I tried the new NIOS version 8.4.4 with the new WAPI version v2.10.3 because new features for MS Servers are implemented (RFE-9632) but still get the same error 400.

Showing results for 
Search instead for 
Do you mean 

Recommended for You