Supply Custom Headers for Json Database
Наши примеры проектов и шаблоны отчётов помогут Вам разобраться в основах работы с нашими продуктами.When a report loads data from a protected JSON endpoint, you can attach authentication headers in the
Add custom headers before the data request.
How it works. The engine applies the headers to its data request, so the report can read endpoints behind token or session protection.
На скриншоте ниже Вы можете увидеть результат выполнения данного кода:

onBeginProcessData event.Add custom headers before the data request.
var report = new Stimulsoft.Report.StiReport();
report.onBeginProcessData = function (args) {
if (args.database === "JSON" && args.command === "GetData" &&
args.pathData && args.pathData.indexOf("/reports/ProtectedDemo.json") >= 0) {
args.headers.push({ key: "X-Auth-Token", value: "*YOUR TOKEN*" });
}
};
report.loadFile("../reports/SimpleListWithProtectedJson.mrt");
report.renderAsync();onBeginProcessData— fires before each data request; inspectargs.database/args.commandto target the right one.args.headers.push({ key, value })— add HTTP headers sent with the JSON fetch, e.g. an auth token.
How it works. The engine applies the headers to its data request, so the report can read endpoints behind token or session protection.
На скриншоте ниже Вы можете увидеть результат выполнения данного кода:
