REST API v1 host categories don't work

  • 20 November 2023
  • 4 replies

Userlevel 1
Badge +7

Hi, I’m trying to add a host into “host categories” in my centreon server using Rest API v1, but it seems to not work properly:
The command

curl --silent --location 'http://centreon.local/centreon/api/index.php?action=authenticate' --header 'centreon-auth-token: some_secret' --header 'Content-Type: application/json' --data '{
"object": "HC",
"action": "addmember",
"values": "mycategorie;"

The result:
400Bad Request → "Bad parameters"

But going to the server and executing the command, it works.

centreon -u admin -p 'some_secret' -o HC -a addmember -v "mycategorie;"

centreon -u admin -p 'some_secret' -o HC -a getmember -v "mycategorie"

I’m missing something?


Best answer by ruben_mendez 23 November 2023, 15:15

View original

4 replies

Userlevel 5
Badge +11


To make requests to Centreon API v1, you need 2 requests

The first one to authenticate, this request will give you a token to use for the second request

The token expire 2 hours after its creation

And then you put the token on the header ‘centreon-auth-token’ with your arguments


In the curl request you write on your message, your request is good but the endpoint you use is the authentication endpoint

The correct endpoint to manipulate Centreon objects (like categories) is




Userlevel 1
Badge +7

Yeah, I know that, some_secret is the token. I often work with centreon API v1. However, host categories don't work.

--header 'centreon-auth-token: some_secret'
Userlevel 5
Badge +11


What version of Centreon are you using?

Can you re-check the endpoint you are using during the second request? The one in your the example is wrong ( “index.php?action=authenticate” instead of “index.php?action=action&object=centreon_clapi”) but it’s maybe a copy-paste mistake

I tested on 23.10 and everything seems to be working for this request


Userlevel 1
Badge +7

My bad is “?action=action&object=centreon_clapi” not “?action=authenticate”.
Thank you 👌