Skip to content

Create new document GroupDocs.Editor RESTful API

Viktor Stupak edited this page Apr 10, 2024 · 1 revision

GroupDocs.Editor RESTful API

GroupDocs.Editor provides a powerful RESTful API for editing various types of documents programmatically. This article provides code examples for calling the GroupDocs.Editor RESTful API to create new documents of different formats: WordProcessing, Spreadsheet, Presentation, and Email.

WordProcessing

const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Accept", "text/plain");

const raw = JSON.stringify({
  "fileName": "document.docx",
  "format": "docx"
});

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: raw,
  redirect: "follow"
};

fetch("https://localhost:32770/WordProcessing/createNew", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

Spreadsheet

const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Accept", "text/plain");

const raw = JSON.stringify({
  "format": "xlsx",
  "fileName": "spreadsheet.xlsx"
});

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: raw,
  redirect: "follow"
};

fetch("https://localhost:32770/Spreadsheet/createNew", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

Presentation

const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Accept", "text/plain");

const raw = JSON.stringify({
  "format": "pptx",
  "fileName": "presentation.pptx"
});

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: raw,
  redirect: "follow"
};

fetch("https://localhost:32770/Presentation/createNew", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

Email

const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Accept", "text/plain");

const raw = JSON.stringify({
  "fileName": "email.emlx",
  "format": "emlx"
});

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: raw,
  redirect: "follow"
};

fetch("https://localhost:32770/Email/createNew", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

For more information about supported document formats in GroupDocs.Editor, refer to the official documentation.

Clone this wiki locally