Get Notification Template Preview
Returns an HTML preview for a specified notification template.
Response
Returns an HTML markup of the notification template that’s shown in the web interface.
The preview markup is wrapped in the JSON object and is stored in its preview
field.
{
"preview": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n\n<html xmlns=\"http://www.w3.org/1999/xhtml\" style=\"margin: 0; padding: 0; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 100%; line-height: 1.6;\">\n<head>\n <meta name=\"viewport\" content=\"width=device-width\">\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n \n</head>\n\n<body bgcolor=\"#f6f6f6\" style=\"margin: 0; padding: 0; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 100%; line-height: 1.6; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; height: 100%; width: 100%;\">\n\n<table class=\"body-wrap\" style=\"margin: 0; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 100%; line-height: 1.6; width: 100%; padding: 20px;\" width=\"100%\">\n <tr style=\"margin: 0; padding: 0; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 100%; line-height: 1.6;\">\n <td style=\"margin: 0; padding: 0; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 100%; line-height: 1.6;\"></td>\n <td class=\"container\" bgcolor=\"#FFFFFF\" style=\"font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 100%; line-height: 1.6; padding: 0 20px; border-left: 4px solid #04930c; border: 1px solid #f0f0f0; display: block; max-width: 600px; margin: 0 auto; clear: both;\">\n <div class=\"content\" style=\"padding: 0; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 100%; line-height: 1.6; max-width: 600px; margin: 0 auto; display: block;\">\n <table style=\"margin: 0; padding: 0; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 100%; line-height: 1.6; width: 100%;\" width=\"100%\">\n <tr style=\"margin: 0; padding: 0; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 100%; line-height: 1.6;\">\n <td style=\"margin: 0; padding: 0; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 100%; line-height: 1.6;\">\n <h1 style=\"padding: 0; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; margin-bottom: 15px; color: #000; line-height: 1.2; font-weight: 200; font-size: 36px; margin: 22px 0 10px;\">Изменение состояния</h1>\n\n<h4 style=\"margin: 0; padding: 0; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #000; line-height: 1.2; font-weight: 200; font-size: 18px; margin-bottom: 30px;\">\n Объект <a href=\"http://127.0.0.1/#/objects/63035c1f5253ca424d6733a1/end-view\" style=\"margin: 0; padding: 0; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 100%; line-height: 1.6; color: #348eda;\">Preview Object</a> перешёл в состояние <span class=\"label state-label\" style=\"margin: 0; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; display: inline; padding: .2em .6em .3em; font-weight: bold; line-height: 1; color: #fff; text-align: center; white-space: nowrap; vertical-align: baseline; border-radius: .25em; font-size: 20px; background-color: #04930c; background: #04930c;\">Working</span>\n</h4>\n\n\n\n<h4 style=\"margin: 0; padding: 0; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; margin-bottom: 15px; color: #000; line-height: 1.2; font-weight: 200; font-size: 18px;\">Сработавшее условие:\n <pre style=\"margin: 0; padding: 0; font-size: 100%; line-height: 1.6; font-family: monospace; background-color: #E9EBEC; margin-top: 15px; padding-left: 5px;\">Condition description.</pre>\n</h4>\n\n<h4 style=\"margin: 0; padding: 0; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; margin-bottom: 15px; color: #000; line-height: 1.2; font-weight: 200; font-size: 18px;\">Состояние объекта:\n <pre style=\"margin: 0; padding: 0; font-size: 100%; line-height: 1.6; font-family: monospace; background-color: #E9EBEC; margin-top: 15px;\">{\n \"reason\": \"preview_reason\"\n}</pre>\n</h4>\n\n<table style=\"margin: 0; padding: 0; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 100%; line-height: 1.6; width: 100%; margin-top: 22px;\" width=\"100%\">\n <tr style=\"margin: 0; padding: 0; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 100%; line-height: 1.6;\">\n <td class=\"padding\" style=\"margin: 0; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 100%; line-height: 1.6; padding: 10px 0;\">\n <p style=\"margin: 0; padding: 0; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; line-height: 1.6; margin-bottom: 10px; font-weight: normal; font-size: 14px;\"><a href=\"http://127.0.0.1/#/objects/63035c1f5253ca424d6733a1/end-view\" class=\"btn-primary\" style=\"margin: 0; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 100%; text-decoration: none; color: #FFF; background-color: #3276b1; border-color: #2c699d; border-width: 10px 20px; line-height: 2; font-weight: bold; margin-right: 10px; padding: 9px 14px; text-align: center; cursor: pointer; display: inline-block; border-radius: 2px;\">Перейти к объекту</a></p>\n </td>\n </tr>\n</table>\n\n </td>\n </tr>\n </table>\n </div>\n </td>\n <td style=\"margin: 0; padding: 0; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 100%; line-height: 1.6;\"></td>\n </tr>\n</table>\n\n</body>\n</html>\n"
}
This notification template looks like this in the web interface:
Example
Request
-
Bash
-
JavaScript
-
NodeJS
-
Python
login=<...>
password=<...>
saymon_hostname=<...>
template_id=<...>
type=pack
url=https://$saymon_hostname/node/api/notification-templates/$template_id/preview/$type
curl -X GET $url -u $login:$password
let login = <...>
let password = <...>
let saymonHostname = <...>
let templateId = <...>
let type = "pack";
let path = "/node/api/notification-templates/" + templateId + "/preview/" + type;
let auth = "Basic " + btoa(login + ":" + password);
let headers = new Headers();
headers.append("Authorization", auth);
let requestOptions = {
method: "GET",
headers: headers
};
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 templateId = <...>
let type = "pack";
let path = "/node/api/notification-templates/" + templateId + "/preview/" + type;
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
let options = {
"method": "GET",
"hostname": saymonHostname,
"headers": {
"Authorization": auth
},
"path": path
};
let req = http.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);
});
});
req.end();
import requests
login = <...>
password = <...>
saymon_hostname = <...>
template_id = <...>
type = "pack"
url = "https://" + saymon_hostname + "/node/api/notification-templates/" + \
template_id + "/preview/" + type
response = requests.request("GET", url, auth=(login, password))
print(response.text)