Skip to main content

Bonjour,

 

In the host panel, there is a radio switch “ Create Service linked to the template too”.

Is it possible to activate it with the rest API?

 

With the REST API, i am creating new hosts from template.

But the new hosts don t have services linked to the template.

Is it possible to add these services linked to the template with the rest API?

 

Thanks for the future answer,

Mathias

 

Hello,

Yes you can do it

  • Via CLAPI
    centreon -u admin -p 'password' -o HOST -a applytpl -v "HOSTNAME"
  • Via APIv1 using cURL
    #First get auth token
    curl -X POST "http://localhost/centreon/api/index.php?action=authenticate" -F 'username=admin' -F 'password=Centreon!123'
    #Output
    {"authToken":"API_TOKEN"}

    #Then send the request using your token
    curl "http://localhost/centreon/api/index.php?action=action&object=centreon_clapi" -H "centreon-auth-token: API_TOKEN" -d '{"action": "applytpl", "object": "HOST", "values": "HOSTNAME"}'

Hello,

Yes you can do it

  • Via CLAPI
    centreon -u admin -p 'password' -o HOST -a applytpl -v "HOSTNAME"
  • Via APIv1 using cURL
    #First get auth token
    curl -X POST "http://localhost/centreon/api/index.php?action=authenticate" -F 'username=admin' -F 'password=Centreon!123'
    #Output
    {"authToken":"API_TOKEN"}

    #Then send the request using your token
    curl "http://localhost/centreon/api/index.php?action=action&object=centreon_clapi" -H "centreon-auth-token: API_TOKEN" -d '{"action": "applytpl", "object": "HOST", "values": "HOSTNAME"}'
     

I will test it.

Thanks again for this quick answer.

 


Test is OK.

Very good ! 😁


Hello @vocum , @mathias :) 
I was searching for this exact same thing, but it doesnt work for me with API. 

root@ip-10-0-12-126 ~]# centreon -u dummy -p 'vuYAQ#9gr!5u5xx' -o HOST -a applytpl -v "REVERSE-PROXY-2"
Return code end :

But if I click the “ Create Service linked to the template too” on the GUI , its works. I didnt had any issues with any other clapi command, seems strange this one fails. 

Centreon v.24.10.3


  • Via CLAPI
    centreon -u admin -p 'password' -o HOST -a applytpl -v "HOSTNAME"
  • Via APIv1 using cURL
    #First get auth token
    curl -X POST "http://localhost/centreon/api/index.php?action=authenticate" -F 'username=admin' -F 'password=Centreon!123'
    #Output
    {"authToken":"API_TOKEN"}

    #Then send the request using your token
    curl "http://localhost/centreon/api/index.php?action=action&object=centreon_clapi" -H "centreon-auth-token: API_TOKEN" -d '{"action": "applytpl", "object": "HOST", "values": "HOSTNAME"}'
     

 

 


Reply