Announcement

Collapse

New forum rules

The forum get new posts rules.

A new user will be moderate for new post. After five valid posts, the user will be to have right to post without moderation.

If you have some issue to post or to connect, contact us.
See more
See less

Centreon REST API 404 Method not found

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Centreon REST API 404 Method not found

    Hi,

    I'm trying to use "hosts status" and "service status" paths from the REST API but I'm getting "404 Object not found" with "Method not found" message. I tried with Postman, Curl, and Python's requests.

    Here is an example of my curl requests:
    curl -s 'http://147.75.33.100:20016/centreon/api/index.php?object=centreon_realtime_hosts&action=li st&viewType=all&status=all' -H 'Content-Type: application/json' -H 'centreon-auth-token: NWFjYzc2YjM4M2RmNjEuMDM4MzY3NTM='

    curl -s 'http://147.75.33.100:20016/centreon/api/index.php?object=centreon_realtime_services&action =list&viewType=all&status=all' -H 'Content-Type: application/json' -H 'centreon-auth-token: NWFjYzc2YjM4M2RmNjEuMDM4MzY3NTM='


    Would love your help on the matter.

    Thank you,
    Shachar

  • #2
    It's normal that you have space here
    Code:
    action=li st
    and here
    Code:
    &action =list
    ?
    CES 3
    Modules: Centreon Syslog / Centreon-NagVis / Mobile-UI

    Centreon depuis le navigateur de votre smartphone c'est par ici: https://github.com/nutzmdm/mobile-UI

    Comment


    • #3
      Seems I have the same issue when trying to use the API, but no typos involved. I can confirm that also curl/wget give the same result.

      Following python script should list hosts with unhandled issues, but I only receive "Method not found"

      Code:
      #!/usr/bin/python3
      
      import requests
      import json
      
      user = "api"
      pwd = "api"
      auth_url = "https://centreon/centreon/api/index.php?action=authenticate"
      auth_data = {'username': user, 'password': pwd}
      auth_token = requests.post(auth_url, data=auth_data)
      auth_headers = {'Content-type': 'application/json', 'centreon-auth-token': auth_token.json()['authToken']}
      
      url = "https://centreon/centreon/api/index.php?object=centreon_realtime_hosts&action=list"
      data = {'viewType': 'unhandled'}
      response = requests.get(url, params=data, headers=auth_headers)
      
      print(response.url)
      print(response.json())

      Comment

      Working...
      X