Hi all,
I'm trying to configure N1KV for Hyper-V using REST API and Powershell. To do it, I'm following this guide: http://www.cisco.com/en/US/docs/switches/datacenter/nexus1000/hyperv/sw/5_2_1_s_m_1_5_1/rest/api/guide/n1000v_rest_api-getting_started.html#wp1056012
So, to configure an IP Pool, I'm using this comands:
$User = "admin"
$Password = ConvertTo-SecureString -String "123qwe!@#$" -AsPlainText -Force
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $Password
$args1 = '{"name" : "IPPOOL01" , "addressRangeStart":"192.168.0.2" ,"addressRangeEnd":"192.168.0.253"}'
$args2 = ConvertFrom-Json -InputObject $args1
Invoke-RestMethod -Uri http://10.10.10.25/api/n1k/ip-pool-template -Credential $Credential -Method Post -Body $args2
But it fails:
Invoke-RestMethod : Parsing application/json content failed
At line:1 char:1
+ Invoke-RestMethod -Uri
http://10.10.10.25/api/n1k/ip-pool-template
-Credential ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand Invoke-RestMethod : Parsing application/json content failed
At line:1 char:1
+ Invoke-RestMethod -Uri http://10.10.10.25/api/n1k/ip-pool-template -Credential ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
I don't know what to do.
Someone else has this kind of problem?