NCReport Rest API Server

NCReportRestAPI is a standalone REST server solution around NCReport reporting library. The server application provides online report generating in PDF format.

How it works

NCReport REST API Report Server is a standalone server application. The report engine is enclosed in a HTTP web service. It runs in itself without any additonal required software components. The service accepts the HTTP requests as a usual web server. After running the specified report, the service returns PDF response via http. The report parameters can be specified by the request url.

NCReport Web Server

System Independent Usage!

Being a standalone server application, NCReport Web Service does not require integration to a web application or a language, it can be simply call via url from any web page or web application such as HTML, PHP, ASP, JSP, NodeJS, ... etc

Setting up

Copy and extract the binary package into a directory whatever you want. Keep the original directory structure. The executable file requires the Qt5.8 runtime libraries, these files are missing from the package.

Configuring

Edit the etc/webapp1.ini file by any text editor. Specify the server settings by example.

Running the server

From the application directory simply run the server in command line mode as follows:

                                        
                                           	cd NCReportWeb
										   	./NCReportWeb -e
                                        
                                    

Usage

Show the main page by the base URL:

                                        
                                           	http://localhost:{port}
                                        
                                    

To run an existing report simply call the report engine by the following http url format:

                                        
                                           	http://localhost:{port}/report?reportid=reportname
                                        
                                    

Where the port number is set in the config file and the reportname is the report file name without extension. The report file must be existed in the report directory. The report directory is specified in the config file. For example:

                                        
                                           	http://localhost:8080/report?reportid=group_demo
                                        
                                    

Adding parameters

Add parameters with URL parameters:

                                        
                                           	http://localhost:8080/report?reportid=group_demo&productid=512
                                        
                                    

Use cases from PHP / Laravel

The following example demonstrates how NCReport Web Service is called from a PHP/Laravel application:

                                        
                                           	Route::get('/reportx', function () {

											  $url="http://localhost:8080/report?reportid=group_demo";
											  $result = file_get_contents($url);
											  $filename = "report1.pdf";
											  if (substr( $result, 0, 5 )=='Error') {
											    return response($result);
											  } else {
											    return Response::make($result, 200, [
											        'Content-Type' => 'application/pdf',
											        'Content-Disposition' => 'inline; filename="'.$filename.'"']);
											  }
											});