Skip to main content
Question

Rest API v2 - Error while searching for service templates

  • November 9, 2024
  • 4 replies
  • 272 views

Rikosp
Forum|alt.badge.img+2

Hi.

My Centreon is IT100 24.04.7 and I’m playing with Rest API v2.

I try to get a service template by searching for its name or its id but I always have a code 500 with the following message: “Error while searching for service templates”.

 

Error while searching by name

 

On the other hand, the search for template services works well when I don’t put any search in query parameters.

 

Ok with no search parameter

What am I doing wrong? Is it a known bug?

4 replies

Forum|alt.badge.img+4
  • Centreonian
  • November 12, 2024

Hello @Rikosp , 

 

I was able to reproduce your problem on a 24.04.6 version.
An internal ticket has been created.


Rikosp
Forum|alt.badge.img+2
  • Author
  • Steward *
  • November 14, 2024

Hello @selkostali 

Thank you for your support.


Rikosp
Forum|alt.badge.img+2
  • Author
  • Steward *
  • November 15, 2024

Hello ​@selkostali 

I’ve another bug to report.

It concerns Host Categories. The query parameters “search” doesn’t work at all. It doesn’t return anything but this time generates no error.

 

No result while searching host category with id = 1

 

And as for service templates, the query without parameter works well and returns all the categories.

 

Ok without query parameters

 


sdouce
Forum|alt.badge.img+12
  • Builder **
  • February 12, 2025

Hello i reproduce the same story  with 24.10 .

 

It works perfectly when i want to retrieve an Host template :

    p_load_tpl_id='search={"name":"'+ f”HOSTTPL_NAME" +'"}'
    def get_htpl_configuration(self, payload):        
        host = f'{self.url}{self.version}/configuration/hosts/templates?{payload}'
        host_centreon = requests.get(host, headers=self.headers, verify=False)
        return host_centreon.json()

 

But for Service Template i get an 500 Error . 

payload=’search={"name":"MSCOSA-VMWARE8"}’

    def get_stpl_configuration(self, payload):        
        stpl = f'{self.url}{self.version}/configuration/services/templates?{payload}'
        stpl_centreon = requests.get(stpl, headers=self.headers, verify=False)
        return stpl_centreon.json()


{'code': 500, 'message': 'Error while searching for service templates'}