I'm trying to create a top level object via Powershell\API but the JSON in the docs doesn't seem to work no matter how i format it.
function New-InsightObjectType {
param(
[STRING]$APIKey,
[STRING]$ObjectSchemaID,
[STRING]$Name,
[STRING]$Description,
[STRING]$IconID
)
$URI = "https://insight-api.riada.io" + "/rest/insight/1.0/objecttype/create"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
$Headers = @{
Authorization = "Bearer $APIKey"
'Content-Type' = 'application/json'
}
$JSON = @"
{
"name": $Name,
"iconId": $IconID,
"objectSchemaId": $ObjectSchemaID
}
Invoke-RestMethod -Uri $URI -Headers $Headers -Body $JSON -Method POST
}
New-InsightObjectType -APIKey $APIKey -Name "Rooms" -IconID "2" -ObjectSchemaID "3" This is the error I get when running
Invoke-RestMethod : {"errorMessages":["Unrecognized token 'Rooms': was expecting (JSON String, Number, Array, Object or token 'null', 'true'
or 'false')\n at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 2, column:
23]"],"errors":{}}
At line:28 char:1
+ Invoke-RestMethod -Uri $URI -Headers $Headers -Body $JSON -Method POS ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Does anyone know what is required?