Hi,
I am writing a PS cmdlet which accepts input from the user, converts it into json(Convert-ToJson) and sends it to REST(Invoke-RestMethod).
My problem here is that I have nested properties for my input, which is getting converted to json format correctly but while sending it to REST the nested property is not getting set.
For exapmle:
I have the json structure as follows:
{
"a" :
{
"b" : "c"
},
"d" : "e"
}
So in my case, other than the property "b" everything else is getting set.
My code looks something like this:
Process{
$input += @{a =@{b="c"}}
$input += @{d = "e"}
$jsonlist = ConvertTo-Json -InputObject $input -Depth 2
$temp = Invoke-Command -ScriptBlock {Invoke-RestMethod -Uri http://something.com/api -Credential $Credential -Method Post -Body $jsonlist }
return
} #end Process
Please can someone let me know if where am i going wrong.
Thanks.