This post is more than 5 years old

1 Rookie

 • 

6 Posts

3314

May 22nd, 2019 20:00

OpenManage Enterprise Powershell API put

Hi,

I am playing around with OpenManage Enterprise API with PowerShell and I can't get the put commands to work for updating networks?

Based on the documentation updating existing values is as easy as 

PUT Used to update a speci€c instance or create a specific€ resource instance with a specific€ identifier.
PUT /AccountService/Accounts('1414')

Example taken from Docs

PUT method for Networks(Id)
	This method updates an existing network.
Description Updates a network.
	Privilege TEMPLATE_MANAGEMENT
HTTP response
	codes
	200
Example Input:
{
 "Id": 43614,
 "Name": "abc-1",
 "Description": "abc-updated",
 "VlanMaximum": 22,
 "VlanMinimum": 19,
 "Type": 1
}

Snippet of my code some variables not shown.

$uri = "https://
  
   /api/NetworkConfigurationService/Networks(26392)"
   

$obj = Invoke-RestMethod -Uri $uri -Method get -Credential $cred

$jsonblock = @{
id = $obj.Id
Description= "Server VLAN"
}
$body = (ConvertTo-Json $jsonblock)
$response = Invoke-RestMethod -Uri $uri -Method Put -Body $body -ContentType 'application/json' -Credential $cred

Invoke-RestMethod : {"error":{"code":"Base.1.0.GeneralError","message":"A general error has occurred. See ExtendedInfo for more
information.","@Message.ExtendedInfo":[{"MessageId":"CGEN1006","MessageId":"CGEN1006","RelatedProperties":[],"Message":"Unable to complete the operation because the
requested URI does not exist or the requested Method is not implemented for the URI.","MessageArgs":[],"Severity":"Critical","Resolution":"Enter a valid URI and retry
the operation."}]}}

What am I missing?

 

Cheers

1 Rookie

 • 

6 Posts

May 27th, 2019 18:00

I seem to have got this to work using WebRequest instead of RestMethod for the PUT method. Still using RestMethod for GET as it creates the network objects for me.

$response = Invoke-WebRequest -Uri $uri -Method Put -Body $body -ContentType 'application/json' -Credential $cred

I also used the certificate policy taken from GitHub

https://github.com/dell/OpenManage-Enterprise/blob/master/Scripts/PowerShell/Set-PowerState.ps1

Cheers

No Events found!

Top