Supply Custom Headers for Json Database
Наши примеры проектов и шаблоны отчётов помогут Вам разобраться в основах работы с нашими продуктами.When a report loads data from a protected JSON endpoint, you may need to send authentication headers.
Preparing the data. Read or create the data source, register it in the report dictionary, synchronize the schema, and render with the supplied records.
На скриншоте ниже Вы можете увидеть результат выполнения данного кода:

Preparing the data. Read or create the data source, register it in the report dictionary, synchronize the schema, and render with the supplied records.
const Stimulsoft = require('stimulsoft-reports-js');
const report = new Stimulsoft.Report.StiReport();
report.onBeginProcessData = function (args) {
if (args.database === "JSON" && args.command === "GetData" &&
args.pathData && args.pathData.endsWith("/ProtectedDemo.json")) {
args.headers.push({ key: "X-Auth-Token", value: "*YOUR TOKEN*" });
}
};
report.loadFile("SimpleListWithProtectedJson.mrt");
report.renderAsync(function () { report.saveDocumentFile("out.mdc"); });The onBeginProcessData event fires before each data request; its args.headers array lets you attach any HTTP headers, so a server-side report can authenticate to secured JSON or REST endpoints.На скриншоте ниже Вы можете увидеть результат выполнения данного кода:
