0

While trying to configure a script using python to write comments using the API i'm encounteringthe following error mesage: {"error":"Unknown API endpoint."}

The code given by NagiosXI API System Reference, system/corecommand is the following:

curl -XPOST "http://192.168.1.239/nagiosxi/api/v1/system/corecommand?apikey=<API_Key>" -d "cmd=ADD_HOST_COMMENT;localhost;1;%user%;This is a test comment"

This translated to python should be something like this:

import requests

url = "http://192.168.1.239/nagiosxi/api/v1/system/corecommand" api_key = "<API_Key>" params = { "cmd": "ADD_HOST_COMMENT", "host_name": "localhost", "entry_time": 1, "author": "%user%", "comment_data": "This is a test comment", "apikey": api_key }

response = requests.post(url, params=params)

if response.status_code == 200: print("Comment added successfully") else: print("Error adding comment: ", response.text)

At the moment i'm getting a 200 response but with the error message previously mentioned: "{"error":"Unknown API endpoint."}"

Currently using NagiosXI version 5.9.3 Both systems are on the same network an "GET" request go through without any hiccups.

Many thanks in advance;

0 Answers0