Add Incident Comment
Adds a comment to the incident’s comment list.
The latest added comment is stored both in the list of comment incidents and a comment
field of the incident.
You can get all comments with Get Incident Comments request.
You cannot add comments to historic incidents. |
Request
Path parameters
Parameter | Type | Description |
---|---|---|
id |
String |
The ID of an incident for which a comment should be added. |
Body parameters
The body should contain a comment as a plain-text string. This string can be formatted as Markdown. See the Showdown documentation for a detailed description of the used Markdown flavor.
You should specify the Content-Type header as text/plain . Otherwise, incident’s comment field will be set to null .
|
Response
The response body is empty.
When you send this request, the comment is added to the incident’s comment list. The latest comment is also stored in the incident’s comment
field.
You can get all comments with Get Incident Comments request.
This request doesn’t work with historic incidents. If you try to add a comment to an incident from the incidents history, the response will have code 500
and the following message in the response body:
{
"message": "Cannot read properties of null (reading 'commentsCount')"
}
Example
Request
-
Bash
-
JavaScript
-
NodeJS
-
Python
login=<...>
password=<...>
saymon_hostname=<...>
incident_id=<...>
url=https://$saymon_hostname/node/api/incidents/$incident_id/comment
curl -X POST $url -u $login:$password \
-H "Content-Type: text/plain" \
--data 'Hello from REST API!'
let login = <...>
let password = <...>
let saymonHostname = <...>
let incidentId = <...>
let path = "/node/api/incidents/" + incidentId + "/comment";
let auth = "Basic " + btoa(login + ":" + password);
let headers = new Headers();
headers.append("Content-Type", "text/plain");
headers.append("Authorization", auth);
let data = "Hello from REST API!";
let requestOptions = {
method: "POST",
headers: headers,
body: data
};
fetch(saymonHostname + path, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
const http = require("http");
let login = <...>
let password = <...>
let saymonHostname = <...>
let incidentId = <...>
let path = "/node/api/incidents/" + incidentId + "/comment";
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
let options = {
"method": "POST",
"hostname": saymonHostname,
"headers": {
"Authorization": auth,
"Content-Type": "text/plain"
},
"path": path
};
let req = https.request(options, function (res) {
let chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
let body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
let data = "Hello from REST API!";
req.write(data);
req.end();
import requests
login = <...>
password = <...>
saymon_hostname = <...>
incident_id = <...>
url = "https://" + saymon_hostname + "/node/api/incidents/" + \
incident_id + "/comment"
headers = {
"Content-Type": "text/plain"
}
comment = "Hello from REST API!"
response = requests.request("POST", url, data=comment,
headers=headers, auth=(login, password))
print(response.text)