Supply Custom Headers for Json Database
Our sample projects and report templates can help you learn the basics of working with our products.On Node.js, authentication headers can be attached while a dashboard reads data from a protected JSON endpoint, via
Add headers, then render and export.
How it works. The engine sends the headers with its JSON fetch, so a server-side export can read protected endpoints.
onBeginProcessData.Add headers, then render and export.
var report = Stimulsoft.Report.StiReport.createNewDashboard();
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("DBSsimp.mrt");
report.exportDocumentAsync(function (pdfData) {
require('fs').writeFileSync('./Dashboard.pdf', Buffer.from(pdfData));
}, Stimulsoft.Report.StiExportFormat.Pdf);onBeginProcessData— fires before the data request; addargs.headersto authenticate.- The rest of the flow is the standard headless load +
exportDocumentAsync.
How it works. The engine sends the headers with its JSON fetch, so a server-side export can read protected endpoints.