New API: Setting downtime not working

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.

2 Likes

Looks like its broken.

This is the Downtime for Host which does not produce any output andy nothing happens on the GUI.

$ curl -X POST “http://localhost/test/check_mk/api/v0/domain-types/downtime/collections/host” --header “Authorization: Bearer automation test” -H “accept: application/problem+json” -H “Content-Type: application/json” -d “{"comment": "Security updates","downtime_type": "host","host_name": "myhost","start_time":"2021-01-09T00:17:28Z","end_time":"2020-01-09T00:55:28Z"}”

This is for the service which results in a error:

$ curl -X POST “http://localhost/test/check_mk/api/v0/domain-types/downtime/collections/service” --header “Authorization: Bearer automation test” -H “accept: application/problem+json” -H “Content-Type: application/json” -d “{"comment": "Security updates","downtime_type": "service","host_name": "myhost","service_descriptions":["Memory"],"start_time":"2021-01-09T00:17:28Z","end_time":"2020-01-09T00:55:28Z"}”

400 Bad Request

Bad Request

Failed to decode JSON object: Expecting value: line 1 column 104 (char 103)

2 Likes

I see the same results using 2.0.0p1 and ansible

Same symptom, API call ended 200 but nothing showed up on GUI.

Was wondering what did I do wrong until I saw this post, thanks.

Very disappointed.

Actually the problem got resolved (for me at least) in the 2.0.0 release (so the very first release after the beta).
Also note that the return code should be 204, not 200.

Are you sure it’s fixed in 2.0.0?

I am on 2.0.0p1 and there’s another reply above using this version too.

Yes it’s not 200 I meant it’s 20x implying it’s checked in ok.

What I heard from the support is they are aware of this and is busy fixing, hopefully 2.0.0p2 will be working right.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact @fayepal if you think this should be re-opened.