How to Use Database Overrides in the BarTender Cloud REST API
Overview
There are times that you may want to replace the information in a database field in your label with new information for a print job. This action is called a Database Override. When making a call to the BarTender Cloud REST API, it could be unclear how this might look in your sending program or client application.
This article will provide you with an example of a print action (including a database override) that you could send to the BarTender Cloud REST API.
Applicable to
BarTender Cloud
Information
Setting Up the Document
Before we get to the example, let's set up the document that goes along with the print action.
- Create a new document in the BarTender Cloud Designer.
- Click the Database Setup icon at the top-left of the screen to open the Database Setup Wizard.
- Click Text File (Embedded) and then hit Next.
- Choose Embedded sample data and then click Next.
- Paste in the following sample data and then click Next.
- Follow through with the rest of the Database Setup Wizard to complete your database connection.
Payload Example
Here is an example of a payload that includes a database override. This example is in JSON, but you can also use YAML. You can use the scroll bar on the right to view the whole example.
[ { "SetVariableAction": { "VariableName": "EventData", "VariableValue": "Id,name,year\r\n1,7325856667720,KS2451-Test1,2020\r\n2,7325856667721,KS2451-Test2,2024\r\n3,1234,test3,22" } }, { "PrintBTWAction": { "DocumentFile": "librarian://main/test.btw", "Name": "Print Document", "Printer": "PDF", "SaveAfterPrint": false, "Copies": 1, "ReturnPrintData": "true", "ReturnPrintSummary": "true", "PrintToFileFileName": "myOutput.PDF", "PrintToFileFolder": "librarian://main/pdf/", "PrintToFileNameVariable": "myPdfOutput", "MakeUniqueOutputFile": "true", "DatabaseOverrides": [ { "Name": "Text", "Type": "VariableName", "DataSourceVariableName": "EventData" } ] } }
For more information, see the resources below.
Additional Resources
BarTender Cloud Online Help - YAML Reference for Database Overrides
BarTender Cloud REST API Overview