Hi,
I'm new to this forum and a starting scripter and I'm trying to figure out what I'm doing wrong here and hope to get some help.
I need to sent an Powershell Core Invoke-RestMethod POST command.
I use this already successfully where the 'body' doesn't contain any square brackets, but with this POST the API requires them according to the developer (a user can have multiple entries for the access- and secretkey).
When I use the CURL POST command with the following Body the API works fine:
-d '[
{
"ObjectStorageLocation":"Location",
"ObjectStorageAccount":1234,
"ObjectStorageGroup":"1234-01",
"ObjectStorageUser":"1234-10",
"Accesskey":"455fs2457jkio",
"Secretkey":"sg56hniitf3466",
"Active":1
}
]'
But when I'm trying to perform the same using Powershell Core Invoke-Restmethod the body isn't accepted:
$body = @[{
ObjectStorageLocation=“Netherlands Location 01”
ObjectStorageAccount=1234
ObjectStorageGroup=“1234-01”
ObjectStorageUser=“1234-10”
Accesskey=“455fs2457jkio”
Secretkey=“sg56hniitf3466”
Active=1
}]
$jsonbody = $body | ConvertTo-Json
$response = Invoke-RestMethod $url -Method Post -Body $jsonbody -Headers $headers
The error is as follows:
422: Unprocessable Entity
The request was well-formed but was unable to be followed due to semantic errors.
Can anyone help me out here?
Thanks in advance!