Skip to main content

Hello,

 

Centreon API V2 has already work? I use Postman or my script python to post an add downtime but it’s doesn’t work.

I use multi format in my postman like:

  • {

        "start_time": "2023-03-04T10:50:00Z",

        "end_time": "2023-03-04T11:50:00Z",

        "is_fixed": "true",

        "author_id": 1453,

        "comment": "Downtime set by admin",

        "resource_id": 629136

        "parent_resource_id":  44527

    }

 

  • <{

        "start_time": "2023-03-04T10:50:00Z",

        "end_time": "2023-03-04T11:50:00Z",

        "is_fixed": "true",

        "author_id": 1453

        "comment": "Downtime set by admin",

        "resource_id": 629136,

        "parent_resource_id": 44527

    }]

Error 500: {"code":500,"message":"Object value found, but an array is required\n"}

 

Cordialy,

Francis

Hello Francis,

I regularly use all three APIs, and I know that the APIv2 has some shortcomings and issues that I encountered during versions 21.04 to 22.10 (which I'm currently using).

Due to the number of downtimes we have to set during maintenance, we prefer to use the endpoint /monitoring/resources/downtimes (set downtime for multiple resources), which works very well.

Here's an example of a request body:

{
  "downtime": {
    "start_time": "2023-01-01T00:00:00+02:00",
    "end_time": "2023-01-01T00:01:00+02:00",
    "is_fixed": true,
    "duration": 3600,
    "comment": "Downtime from APIv2",
    "with_services": true
  },
  "resources": b
    {
      "type": "service",
      "id": 10,
      "parent": {
        "id": 5
      }
    }
  ]
}

For information: the "duration" value is not taken into account. I only use the "start_time" and "end_time" values to define the downtime duration (be careful with the date format and the time zone).

If I have time tomorrow, I'll try to test your endpoint.

Based on my experience, I recommend using the following endpoints:

- /monitoring/hosts/{host_id}/services/{service_id}/downtimes to set a single downtime.
or
- /monitoring/resources/downtime to set multiple downtimes simultaneously.


Reply