# Create HTTP Monitor using API via PowerShell script

**URL:** <https://community.dynatrace.com/t/create-http-monitor-using-api-via-powershell-script/37616>\
**Category:** Dynatrace API\
**Tags:** dynatrace-api\
**Created:** [December 8, 2022, 7:29am UTC](https://community.dynatrace.com/t/create-http-monitor-using-api-via-powershell-script/37616 "2022-12-08T07:29:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sriramprabhakar](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@sriramprabhakar](https://community.dynatrace.com/u/sriramprabhakar)\
**Post date:** [December 8, 2022, 7:29am UTC](https://community.dynatrace.com/t/create-http-monitor-using-api-via-powershell-script/37616/1 "2022-12-08T07:29:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zofiatarant](https://avatars.discourse-cdn.com/v4/letter/z/b77776/32.png) [@zofiatarant](https://community.dynatrace.com/u/zofiatarant)\
**Post date:** [December 19, 2022, 11:48am UTC](https://community.dynatrace.com/t/create-http-monitor-using-api-via-powershell-script/37616/2 "2022-12-19T11:48:50Z")

</div>

Hi! You’re missing quotation marks around the location ID. Please try:

```javascript
$location='["GEOLOCATION-2FD31C834DE4D601"]'

```
