Hello Community,
I am trying to set the monitoring mode for a specific host using API with powershell. With cURL was very easy, with Powershell i am struggling. I have created the script below, but i get the following error:
Invoke-RestMethod : {“error”:{“code”:403,“message”:“Token is missing required scope. Use one of: settings.write (Write
settings)”}}
Unfortunately, I didn’t manage to find an example with a POST using Powershell.
Kind regards,
Mario
$Token = ‘dt0c01.RM2ATDEG5773MBHGFGHDFGDFGHDGHKFDGHFDGHFDGFDGFDGHDFKDGHDHGDFGDGDGHDGHDG’
$Body = @{
schemaId = ‘builtin:host.monitoring.mode’
schemaVersion = ‘1.3’
scope = ‘HOST-5F30AHGJHKGHJGHK’
value = @{
monitoringMode = ‘FULL_STACK’
}
}
$Params = @{
Uri = ‘https://{environmentid}.live.dynatrace.com/api/v2/settings/objects’
Method = ‘POST’
Body = ‘[’ + ($Body | ConvertTo-Json) + ‘]’
Headers = @{
“Content-Type” = ‘application/json; charset=utf-8’
“Authorization” = ‘Api-Token’ + ’ ’ + $Token
}
}
Invoke-RestMethod @Params