This example shows how to supply custom headers for JSON Database. First, create the new report instance:
// Creating new report
const report = new Stimulsoft.Report.StiReport();
console.log("New report created");

...

Then, in onBeginProcessData event handler add custom HTTP headers:
...

// In `onBeginProcessData` event handler add custom HTTP headers
report.onBeginProcessData = function (args) {
    if (
        args.database === "JSON" && 
        args.command === "GetData" && 
        args.pathData && args.pathData.endsWith("/ProtectedDemo.json")
    ) {
        // Add custom header to pass through server protection
        args.headers.push({key: "X-Auth-Token", value: "*YOUR TOKEN*"});
    }
};
	
...

After that, load and render report:
...

// Load report from url
report.loadFile("SimpleListWithProtectedJson.mrt");
console.log("Report template loaded");
// Renreding report
report.renderAsync(function () {
	console.log("Report rendered. Pages count: ", report.renderedPages.count);

	// Saving rendered report to file
	report.saveDocumentFile("SimpleListWithProtectedJson.mdc");
	console.log("Rendered report saved");
});

Auf dem Screenshot unten Sie können das Ergebnis des Beispiel-Codes ansehen:

Supply Custom Headers for JSON Database

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.