<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: api delete and create maintenance window in Dynatrace API</title>
    <link>https://community.dynatrace.com/t5/Dynatrace-API/api-delete-and-create-maintenance-window/m-p/42359#M160</link>
    <description>&lt;P&gt;Delete of maintenance window should of course work with a HTTP DELETE request to following path:&lt;/P&gt;&lt;P&gt;HTTP DELETE &lt;A href="https://{your_domain}/api/v1/maintenance/theWindowId"&gt;https://{your_domain}/api/v1/maintenance/theWindo...&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Also an update of an existing config is possible, just use the same HTTP POST payload and change some infos. &lt;/P&gt;&lt;P&gt;HTTP POST &lt;A href="https://%7Byour_domain%7D/api/v1/maintenance/theWindowId"&gt;https://{your_domain}/api/v1/maintenance&lt;/A&gt;&lt;/P&gt;&lt;P&gt;change the values within your maintenance window config object but keep the same "id" : "theWindowId" field.&lt;/P&gt;&lt;P&gt;The POST with your scope does not work because of wrong format. See my example below:&lt;/P&gt;&lt;P&gt;"scope" : { &lt;/P&gt;&lt;P&gt;    "entities" : [ ], &lt;/P&gt;&lt;P&gt;    "matches" : [ &lt;/P&gt;&lt;P&gt;         {&lt;BR /&gt;"type" : "HOST",&lt;BR /&gt;"tags" : [ {"key" : "myTag" }&lt;BR /&gt;]&lt;BR /&gt;}, &lt;/P&gt;&lt;P&gt;        {&lt;BR /&gt;"type" : "SERVICE",&lt;BR /&gt;"tags" : [ {"key" : "myTag" }&lt;BR /&gt;]&lt;BR /&gt;} &lt;/P&gt;&lt;P&gt;    ] &lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;And please keep in mind that at least one service and one host must have that tag 'myTag' otherwise the call fails because there is no match.&lt;/P&gt;</description>
    <pubDate>Wed, 28 Feb 2018 09:14:14 GMT</pubDate>
    <dc:creator>wolfgang_beer</dc:creator>
    <dc:date>2018-02-28T09:14:14Z</dc:date>
    <item>
      <title>api delete and create maintenance window</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/api-delete-and-create-maintenance-window/m-p/42355#M156</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am writing a powershell script to delete and create maintenance windows.  Firstly, if I try to create a maintenance window for the the API and theres already a window of the same name, does it update the existing window or does it just fail (i.e. do I need to delete the existing window first?).&lt;/P&gt;&lt;P&gt;Secondly, when trying to delete a window I am running the following command..&lt;/P&gt;&lt;PRE&gt;(Invoke-WebRequest -Headers @{"Authorization"="Api-Token $token"} "https://$id.live.dynatrace.com/api/v1/maintenance").Content | ConvertFrom-Json&lt;BR /&gt;id               : TEST&lt;BR /&gt;type             : Planned&lt;BR /&gt;description      : test&lt;BR /&gt;suppressAlerts   : False&lt;BR /&gt;suppressProblems : False&lt;BR /&gt;scope            : &lt;BR /&gt;schedule         : @{t......}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Invoke-WebRequest -Method Delete -Headers @{"Authorization"="Api-Token $token"} &lt;BR /&gt;"https://$id.live.dynatrace.com/api/v1/maintenance/TEST" &lt;BR /&gt;&lt;BR /&gt;StatusCode : 204 StatusDescription : No Content Content : {} RawContent : HTTP/1.1 204 No Content Access-Control-Allow-Origin: * Access-Control-Allow-Methods: GET, POST, DELETE, PUT Access-Control-Allow-Headers: * X-RateLimit-Limit: 50 X-RateLimit-Remaining: 49 X-Rate... Headers : {[Access-Control-Allow-Origin, *], [Access-Control-Allow-Methods, GET, POST, DELETE, PUT], [Access-Control-Allow-Headers, *], [X-RateLimit-Limit, 50]...} RawContentLength : 0&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;I get the status 204 but the window does not get deleted.  Can someone point out what I am doing wrong? Sure it is something obvious.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 15:58:49 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/api-delete-and-create-maintenance-window/m-p/42355#M156</guid>
      <dc:creator>grant_drage</dc:creator>
      <dc:date>2017-11-15T15:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: api delete and create maintenance window</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/api-delete-and-create-maintenance-window/m-p/42356#M157</link>
      <description>&lt;P&gt;Not got the delete to work yet via the API. Have managed to get it to create a window using the API but only if there is no scope.  what I am doing is using powershell to do an invoke webrequest to get all maintenance windows, then cycling through looking for one of a particular name. When it finds it, the script changes the start and end times, and does webrequest to post it back either with the same id or a new one (the name of the window).  This works if I choose to efficitively amend a window that affects the 'entire environment' but I get the following error when trying to create a window with scope.&lt;/P&gt;&lt;PRE&gt;Invoke-WebRequest -Headers @{"Authorization"="Api-Token $token"} "https://$id.live.dynatrace.com/api/v1/maintenance" -ContentType 'application/json' -Method POST -Body ($window | ConvertTo-Json)&lt;BR /&gt;&lt;BR /&gt;Invoke-WebRequest : {"error":{"code":400,"message":"failed processing (parsing, generating) JSON content"}}&lt;BR /&gt;At C:\Scripts\ruxit api.ps1:26 char:9&lt;BR /&gt;+         Invoke-WebRequest -Headers @{"Authorization"="Api-Token $token"} "https: ...&lt;BR /&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException&lt;BR /&gt;    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Nov 2017 11:44:16 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/api-delete-and-create-maintenance-window/m-p/42356#M157</guid>
      <dc:creator>grant_drage</dc:creator>
      <dc:date>2017-11-16T11:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: api delete and create maintenance window</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/api-delete-and-create-maintenance-window/m-p/42357#M158</link>
      <description>&lt;P&gt;Here is the JSON object I am trying to send....&lt;/P&gt;&lt;PRE&gt;{&lt;BR /&gt;    "id":  "UAT",&lt;BR /&gt;    "type":  "Planned",&lt;BR /&gt;    "description":  "Testing maintenance window",&lt;BR /&gt;    "suppressAlerts":  true,&lt;BR /&gt;    "suppressProblems":  true,&lt;BR /&gt;    "scope":  {&lt;BR /&gt;                  "entities":  [&lt;BR /&gt;                                   "SYNTHETIC_TEST-00000000000037DF"&lt;BR /&gt;                               ],&lt;BR /&gt;                  "matches":  [&lt;BR /&gt;                                  "@{type=HOST; tags=System.Object[]}"&lt;BR /&gt;                              ]&lt;BR /&gt;              },&lt;BR /&gt;    "schedule":  {&lt;BR /&gt;                     "type":  "Once",&lt;BR /&gt;                     "timezoneId":  "Europe/London",&lt;BR /&gt;                     "maintenanceStart":  "2017-11-16 11:41",&lt;BR /&gt;                     "maintenanceEnd":  "2018-11-16 11:41"&lt;BR /&gt;                 }&lt;BR /&gt;}&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Nov 2017 11:44:43 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/api-delete-and-create-maintenance-window/m-p/42357#M158</guid>
      <dc:creator>grant_drage</dc:creator>
      <dc:date>2017-11-16T11:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: api delete and create maintenance window</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/api-delete-and-create-maintenance-window/m-p/42358#M159</link>
      <description>&lt;P&gt;Run the same script with no scope set, and it works fine...&lt;/P&gt;&lt;PRE&gt;{&lt;BR /&gt;    "id":  "TEST",&lt;BR /&gt;    "type":  "Planned",&lt;BR /&gt;    "description":  "test",&lt;BR /&gt;    "suppressAlerts":  false,&lt;BR /&gt;    "suppressProblems":  false,&lt;BR /&gt;    "scope":  null,&lt;BR /&gt;    "schedule":  {&lt;BR /&gt;                     "type":  "Once",&lt;BR /&gt;                     "timezoneId":  "Europe/London",&lt;BR /&gt;                     "maintenanceStart":  "2017-11-16 11:45",&lt;BR /&gt;                     "maintenanceEnd":  "2018-11-16 11:45"&lt;BR /&gt;                 }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;StatusCode        : 204&lt;BR /&gt;StatusDescription : No Content&lt;BR /&gt;Content           : {}&lt;BR /&gt;RawContent        : HTTP/1.1 204 No Content&lt;BR /&gt;                    Access-Control-Allow-Origin: *&lt;BR /&gt;                    Access-Control-Allow-Methods: GET, POST, DELETE, PUT&lt;BR /&gt;                    Access-Control-Allow-Headers: *&lt;BR /&gt;                    X-RateLimit-Limit: 50&lt;BR /&gt;                    X-RateLimit-Remaining: 49&lt;BR /&gt;                    X-Rate...&lt;BR /&gt;Headers           : {[Access-Control-Allow-Origin, *], [Access-Control-Allow-Methods, GET, POST, DELETE, PUT], [Access-Control-Allow-Headers, *], [X-RateLimit-Limit, 50]...}&lt;BR /&gt;RawContentLength  : &lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Nov 2017 11:47:28 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/api-delete-and-create-maintenance-window/m-p/42358#M159</guid>
      <dc:creator>grant_drage</dc:creator>
      <dc:date>2017-11-16T11:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: api delete and create maintenance window</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/api-delete-and-create-maintenance-window/m-p/42359#M160</link>
      <description>&lt;P&gt;Delete of maintenance window should of course work with a HTTP DELETE request to following path:&lt;/P&gt;&lt;P&gt;HTTP DELETE &lt;A href="https://{your_domain}/api/v1/maintenance/theWindowId"&gt;https://{your_domain}/api/v1/maintenance/theWindo...&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Also an update of an existing config is possible, just use the same HTTP POST payload and change some infos. &lt;/P&gt;&lt;P&gt;HTTP POST &lt;A href="https://%7Byour_domain%7D/api/v1/maintenance/theWindowId"&gt;https://{your_domain}/api/v1/maintenance&lt;/A&gt;&lt;/P&gt;&lt;P&gt;change the values within your maintenance window config object but keep the same "id" : "theWindowId" field.&lt;/P&gt;&lt;P&gt;The POST with your scope does not work because of wrong format. See my example below:&lt;/P&gt;&lt;P&gt;"scope" : { &lt;/P&gt;&lt;P&gt;    "entities" : [ ], &lt;/P&gt;&lt;P&gt;    "matches" : [ &lt;/P&gt;&lt;P&gt;         {&lt;BR /&gt;"type" : "HOST",&lt;BR /&gt;"tags" : [ {"key" : "myTag" }&lt;BR /&gt;]&lt;BR /&gt;}, &lt;/P&gt;&lt;P&gt;        {&lt;BR /&gt;"type" : "SERVICE",&lt;BR /&gt;"tags" : [ {"key" : "myTag" }&lt;BR /&gt;]&lt;BR /&gt;} &lt;/P&gt;&lt;P&gt;    ] &lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;And please keep in mind that at least one service and one host must have that tag 'myTag' otherwise the call fails because there is no match.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 09:14:14 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/api-delete-and-create-maintenance-window/m-p/42359#M160</guid>
      <dc:creator>wolfgang_beer</dc:creator>
      <dc:date>2018-02-28T09:14:14Z</dc:date>
    </item>
  </channel>
</rss>

