function getDocAPIBody(id) {

  // Call DOC API REST endpoint to get the file
  let url = `https://docs.googleapis.com/v1/documents/${id}`;

  var response = UrlFetchApp.fetch(url, {
    method: 'GET',
    headers: {
      Authorization: 'Bearer ' + ScriptApp.getOAuthToken(),
    },
    muteHttpExceptions: true
  });

  if (response.getResponseCode() !== 200) {
    throw new Error(`Drive API returned error \
    ${response.getResponseCode()} :\
     ${response.getContentText()}`);
  }

  let file = response.getContentText();
  let data = JSON.parse(file);

  return data.body.content;
}
Fetches the body of given document, using DocsApi.

@param {string} id The Google Document file ID.
@return {string} The body of the Google Document.