Bibliothekselemente aufzählen

Nachdem Sie durch Aufzählen der Print Portal-Bibliotheken die ID des Ursprungsordners erhalten haben, können Sie die Bibliothekselemente (Dokumente und Unterordner) eines bestimmten Ursprungsordners auflisten.

GeschlossenBibliothekselemente aufzählen

Die Ausgabeseite im Browser ist im Format JSON, hier werden Elemente im Librarian-Ursprungsordner aufgelistet. In diesem Beispiel gibt es drei Objekte. In einem weiteren Schritt dieses Tutorials werden wir „TLC39 Laser_53_rf.btw“ drucken.

{

"library":{"id":"de6940a6-ff73-465b-aaf2-d39504420fa6",

"name":"Librarian",

"description":"Files that have been added to Librarian.",

"order":1,

"fileFilter":"*.btw",

"relativePath":"lib://","validVisibleUsers":[]},

"contents":["Document1.btw","BMW.btw","TLC39 Laser_53_rf.btw"]

}

GeschlossenJavaScript-Beispiel

Kopieren
/*-----------------------------------------------------------------------------------
Display files from a root folder
*/
let basePrintPortalURL = "https://example.com/Bartender/";
let route = "libraries/";
let id = "9890beae-db51-4b74-a132-d6430a06a192"

fetch(basePrintPortalURL + route + id)
.then(response => response.json())
.then(result => {
  console.log(result);

  // The following will display a list of templates available in the specific library
  const fileList = result.contents;
  fileList.forEach(template => console.log(template));

  // Displays the name of the library
  console.log(result.name);

  // Displays the specific error message in case of a failed request
  console.log(result.errors.id);
  
  // Displays the title of the error message
  console.log(result.title);

  // Displays the error message status code
  console.log(result.status);

})
.catch(error => {
  console.error('There has been a problem with your fetch operation: ', error.message);
});