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.
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.

By using this website, you agree to the use of cookies for analytics and personalized content. Cookies store useful information on your computer to help us improve efficiency and usability. For more information, please read the privacy policy and cookie policy.