Skip steps 1 and 2 if you already have a Flashreport account.
Please note that if you are using Flashreport from a PaaS marketplace such as Cloud Foundry, steps 1 and 2 will be handled from that marketplace.

Step 1 : Create an account on Flashreport.io

Step 2 : Login with that account on Flashreport.io

Step 3 : Get your API key

Access the control panel screen, click on your free subscription to open it, and click on the view key button.

Step 4 : Prepare your environment

Step 5 : Generate your report

  • Open a command prompt in your test directory, and execute this Curl command. Insert the API key you retrieved from step 3, keep the trailing colon.
  • curl -X POST --header "Content-Type:application/json;charset=UTF-8" --user "YOUR API KEY:" -d @orders-smallest.json http://gateway.flashreport.io/api/v1/report/new
    
  • Note that a UUID appears after the CURL command has completed

Step 6 : View your PDF

Access the reports screen, click on the download icon of the first row.

Step 7 : Register a template

  • Download a sample JRXML file that matches the structure of the JSON file
  • Access the templates screen, enter orders as template name, choose the JRXML file you just downloaded, and press Add template.
  • The orders template appears in the list of registered templates.

Step 8 : Generate a report using the template

  • Go back to your command prompt, and execute this Curl command. Insert the API key you retrieved from step 3, keep the trailing colon.
  • Specify the template you want to use by appending ?template=orders at the end of the URL
  • curl -X POST --header "Content-Type:application/json;charset=UTF-8" --user "YOUR API KEY:" -d @orders-smallest.json http://gateway.flashreport.io/api/v1/report/new?template=orders
    
  • Note that a UUID appears after the CURL command has completed

Step 9 : View your template based PDF

Access the reports screen again, click on the download icon of the first row.

Because we used a template, we were able to use custom headers and footers, sort data per country, count orders per city, and include a pie chart. Designing a template is extra work, but is necessary to have better looking reports. We recommend that you use Jaspersoft Studio to design your template and test it with your data file.

Congratulations!

You have successfully generated a PDF document from JSON data, with and without using a template.

While using CURL to generate the report is useful for testing Flashreport api, it's not the usual way to do it. In most cases, you'll write code in your favourite programming language that generates the same HTTP POST command than CURL. This code will run in the system that has the information you want to generate PDF documents from. That system might be a business application, a big data process, a connected device...

Next steps

Read the documentation to learn about additional options.

Check our code samples on GitHub