This example shows how to supply custom headers for JSON Database. First, create the new dashboard:
// Creating new dashboard
var report = Stimulsoft.Report.StiReport.createNewDashboard();
console.log("New dashboard 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 dashboard template and export it to PDF:
...

// Loading dashboard template
report.loadFile("DBSsimp.mrt");
console.log("Dashboard template loaded");

// Export to PDF
report.exportDocumentAsync((pdfData) => {
    // Converting Array into buffer
    var buffer = Buffer.from(pdfData);

    // File System module
    var fs = require('fs');

    // Saving string with rendered dashboard in PDF into a file
    fs.writeFileSync('./Dashboard.pdf', buffer);
    console.log("Dashboard saved into PDF-file.");
}, Stimulsoft.Report.StiExportFormat.Pdf);

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.