CURL is a command that allows you to easily download data from any address. In this guide, we will show you how to read certain data from Flexi using the command line.
You can use this for simple scripting.
In the following examples, we will always use these parameters:
curl -u jmeno:heslo -L -o soubor.pdf
-uspecifies the authorization credentials for Flexi.-fspecifies that if an error occurs on the server side, nothing should be written to the output and the process should terminate immediately.-Lfollows redirects. If the URL structure changes in the future, this parameter ensures that the script will continue to work.-oensures that the returned data will be written to a file.-kif you are using a custom installation with an automatically generated certificate, it is necessary to ignore the untrusted certificate authority.
Writing a list of unpaid invoices to PDF
If you want to write all unpaid invoices to a PDF file, you can use the following command:
curl -u winstrom:winstrom -k -L -f "https://demo.flexibee.eu:5434/c/demo/faktura-vydana/(stavUhrK%20!=%20%27stavUhr.uhrazeno%27).pdf" -o neuhrazene-faktury.pdf
This command takes all invoices, applies a filter stavUhrK != 'stavUhr.uhrazeno' to them, i.e. all invoices that are not in the paid status, and writes them as a PDF to the file neuhrazene-faktury.pdf (overview of supported formats).
Filters must be correctly URL-encoded. When manually creating a filter, you can simply type it unencoded in the Firefox browser. When you then copy it to the clipboard, Firefox will re-encode it.
Converting all company contacts to vCard e-business cards
If you want to convert all company contacts to vCard e-business cards, you can use the following command:
curl -u winstrom:winstrom -k -f -L https://demo.flexibee.eu:5434/c/demo/adresar.vcf -o adresar.vcf
Creating a new invoice
In order to create an invoice, we will first need an XML file containing the data. We will write the following content to the file faktura.xml.
<?xml version="1.0"?><winstrom version="1.0"> <faktura-vydana> <typDokl>code:FAKTURA</typDokl> <firma>code:WINSTROM</firma> <popis>Moje faktura z CURL</popis> <sumZklZakl>1000.0</sumZklZakl> <bezPolozek>true</bezPolozek> </faktura-vydana></winstrom>
We can now run the following command:
curl -u winstrom:winstrom -k -L https://demo.flexibee.eu:5434/c/demo/faktura-vydana.xml -T faktura.xml
