This example shows how to supply custom headers for JSON Database. First, create a new report instance:

<script type="text/javascript">
	// Create a new report instance
	var report = new Stimulsoft.Report.StiReport();

...

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.indexOf("/reports/ProtectedDemo.json") >= 0
		) {
			// Add custom header to pass through backend server protection
			args.headers.push({key: "X-Auth-Token", value: "*YOUR TOKEN*"});
		}
	};
	
...

After that, load report from URL and render it:
...

	// Load report from url
	report.loadFile("../reports/SimpleListWithProtectedJson.mrt");
	// Render report
	report.renderAsync(function () {
		document.getElementById("savePdf").disabled = false;
	});
	
...

Finally, export report to PDF format and save it to file:
...

	// Export report to PDF format and save to file
	function saveReportPdf() {
		// Export to PDF
		report.exportDocumentAsync(function (pdfData) {
			// Get report file name
			var fileName = report.reportAlias;
			// Save data to file
			Stimulsoft.System.StiObject.saveAs(pdfData, fileName + ".pdf", "application/pdf");
		}, Stimulsoft.Report.StiExportFormat.Pdf);
	}
</script>

На скриншоте ниже Вы можете увидеть результат выполнения данного кода:

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.