08 Dec 2022 07:29 AM - last edited on 12 Dec 2022 10:31 AM by Ana_Kuzmenchuk
Hi,
I am trying to automate the creation of an HTTP monitor using PowerShell scripts. However, I always get a 400 when I try to pass the value of the location via variable. Please see below
[array]$location = "[GEOLOCATION-2FD31C834DE4D601]"
Write-Host $location
$headers = @{
Authorization= ' Api-Token xxxxxxxxxxx'
}
$body = '{
"frequencyMin": 10,
"anomalyDetection": {
"outageHandling": {
"globalOutage": true,
"localOutage": false,
"localOutagePolicy": {
"affectedLocations": 1,
"consecutiveRuns": 3
}
},
"loadingTimeThresholds": {
"enabled": false
}
},
"type": "HTTP",
"name": "Created_via_Devops_pipeline",
"locations": $location ,
"enabled": true,
"keyPerformanceMetrics": {
"loadActionKpm": "VISUALLY_COMPLETE",
"xhrActionKpm": "VISUALLY_COMPLETE"
},
"script": {
"version": "1.0",
"requests": [{
"description": "CreatedByDevops",
"url": "https://{environmentid}.live.dynatrace.com/api/v1/synthetic/monitors -Method post -Headers $headers -ContentType 'application/json' -body $body
Solved! Go to Solution.
19 Dec 2022 11:48 AM
Hi! You're missing quotation marks around the location ID. Please try:
$location='["GEOLOCATION-2FD31C834DE4D601"]'