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 ! 😁


Reply