Enumerating Available Printers

By enumerating the available printers, you will be able to identify the printer that you want to print to.

ClosedTo enumerate available printers

The return page in the browser is JSON format content that enumerates printers. In this example, there are three printers. In a subsequent step in this tutorial, we will print to the PDF printer.

{

"serverPrinters":["PDF","TEC B-452H","TEC KP-20"],

"remotePrinters":[]

}

ClosedJavaScript Example

Copy
/*---------------------------------------------------------------------------------------
Enumerate available printers */

let basePrintPortalURL = "https://example.com/Bartender/api/v1/";
let printPortalPrinters = "printers/";
let token = "token_value_from_authentication_call";

fetch(basePrintPortalURL + printPortalPrinters, {
    method: 'get',
    headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer ' + token
  },
    })
    .then(response => response.json())
    .then(result => {
        console.log('Success:', result);
      })
      .catch(error => {
        console.error('Error:', error);
      });