Hi All
I am trying to write a Hash table for the below JSON code in power shell script and getting INVALID_JSON_ATTRIBUTE error
Example JSON CODE
"actions" : [ {
"action" : "CONN_POOL_STATS",
"resources" : [ {
"cluster" : true
} ]
}, {
"action" : "COLL_STATS",
"resources" : [ {
"collection" : "",
"db" : "staging"
} ]
} ]
Here is the Hash table i tried for the above JSON code and assigned it to a variable newrole and using Convertto-JSON at the end.
$newrole = @{
actions = @(
@{
action = 'CONN_POOL_STATS'
resources = @(
@{
cluster = "true"
}
)
}
@{
action = 'COLL_STATS'
resources = @(
@{
collection = ''
db = 'staging'
}
)
}
)
$newrole2 = $newrole | ConvertTo-Json
Here is the Error while executing powershell script. Can anyone please help me identify the error with hash table code
Invoke-RestMethod : {"detail":"Received JSON for the actions attribute does not match expected
format.","error":400,"errorCode":"INVALID_JSON_ATTRIBUTE","parameters":["actions"],"reason":"Bad Request"}