17 Sep 2025 12:35 PM
Hi,
I'm trying to build a workflow that enable/disable maintenance windows.
To do that, I'm using the PUT method.
This is the code that I'm using for this part:
async function createMaintenanceWindow() {
try {
const CREDENTIAL_OR_TOKEN = 'mytoken';
const apiToken = await resolveApiToken(CREDENTIAL_OR_TOKEN);
const baseUrl = 'https://{environmentid}.live.dynatrace.com';
const maintenanceWindow = {
"value": {
"enabled": false,
"generalProperties": {
"name": "my windows",
"description": "my window",
"maintenanceType": "PLANNED",
"suppression": "DONT_DETECT_PROBLEMS",
"disableSyntheticMonitorExecution": true
},
"schedule": {
"scheduleType": "DAILY",
"dailyRecurrence": {
"timeWindow": {
"startTime": "07:00:00",
"endTime": "10:00:00",
"timeZone": "Europe/Madrid"
},
"recurrenceRange": {
"scheduleStartDate": "2025-08-18",
"scheduleEndDate": "2028-01-01"
}
}
},
"filters": [
{
"entityType": "SYNTHETIC_TEST",
"entityId": null,
"entityTags": [
"sinteticos"
],
"managementZones": []
}
]
}
}
const response = await fetch(`${baseUrl}/api/v2/settings/objects/objectIDXXXXXXXXXXXXXXXXXXXXXXXXXXXX`, {
method: 'PUT',
headers: {
'Accept': 'application/json; charset=utf-8',
'Content-Type': 'application/json; charset=utf-8',
'Authorization': `Api-Token ${apiToken}`
},
body: JSON.stringify([maintenanceWindow])
});
If I launch in Swagger the content of "const maintenanceWindow", it works. But the workflow returns 400 Bad Request.
I suspect that the problem is the PUT due to the objectID param.
Is it correct sending the ID on this way fetch(`${baseUrl}/api/v2/settings/objects/objectIDXXXXXXXXXXXXXXXXXXXXXXXXXXXX` or I have to past this parameter in other way?
Thanks in advance.
Regards,
Elena.