Hello there,
first off: I’m loving the 2.0 update and the new API looks great. Can’t wait to see how far you’ll expand it.
Unfortunately I’m having some problems with one of the features of the new API, namely scheduling downtimes.
Lets start with the formalities:
CMK version : 2.0.0b3 (CRE)
OS version : Ubuntu 20.04.1 LTS
Error message : none, return code is 204
Description:
Sending a POST request to the new API to create a new host related or service related scheduled downtime results in nothing happening.
Expectation:
Correct POST request to API creates new scheduled downtime
Additional Info:
To see if I’m using the API wrong I tested a few things, which all worked:
- Show all scheduled downtimes
- Delete a scheduled downtime
- Show all hosts
- Create new host
- Create new timerange
Only the creation of downtimes doesn’t work.
Complete details:
I’m using Insomnia as a CURL frontend to interact with the API.
Here is the data concerning my API call for a host related downtime:
* Preparing request to http://<redacted_server_and_site>/check_mk/api/v0/domain-types/downtime/collections/host
* Current time is 2021-01-08T15:46:02.540Z
* Using libcurl/7.69.1-DEV OpenSSL/1.1.1d zlib/1.2.11 WinIDN libssh2/1.9.0_DEV nghttp2/1.40.0
* Using default HTTP version
* Disable timeout
* Enable automatic URL encoding
* Enable SSL validation
* Enable cookie sending with jar of 4 cookies
* Connection 29 seems to be dead!
* Closing connection 29
* Trying <redacted_IP>:80...
* Connected to <redacted_server> (<redacted_IP>) port 80 (#30)
> POST /<redacted_site>/check_mk/api/v0/domain-types/downtime/collections/host HTTP/1.1
> Host: <redacted_server>
> User-Agent: insomnia/2020.5.0
> Content-Type: application/json
> Authorization: Bearer <redacted_user> <redacted_password>
> Accept: */*
> Content-Length: 159
| {
| "comment": "API Test",
| "downtime_type": "host",
| "host_name": "cuda009",
| "start_time": "2021-01-05T17:32:28Z",
| "end_time": "2021-01-22T17:32:28Z"
| }
* upload completely sent off: 159 out of 159 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 204 NO CONTENT
< Date: Fri, 08 Jan 2021 15:46:02 GMT
< Server: Apache
< Content-Security-Policy: default-src 'self' 'unsafe-inline' 'unsafe-eval' ssh: rdp:; img-src 'self' data: https://*.tile.openstreetmap.org/ ; connect-src 'self' https://crash.checkmk.com/ ; frame-ancestors 'self' ; base-uri 'self'; form-action 'self' javascript: 'unsafe-inline'; object-src 'self'; worker-src 'self' blob:
< X-Content-Type-Options: nosniff
I double-checked the host name and it matches (case sensitive).
Service related downtimes work exactly the same, by completing the request and a 204 confirmation, but the nothing shows up in check_mk.
If anyone could at least confirm if it works for them or if it’s generally not working right now that would already be a great help.