Search code examples
google-slides-api

Google Slides API returning a 500 server error


Using the Javascript client, I'm submitting a large number of requests to batchUpdate(). The code below was working perfectly until a few hours ago. I've tried reducing the number of requests as suggested here but that seems to make no difference. See below for the code I'm using, it's pretty simple. The template being copied is open so it should run assuming you put a client_id and api key in there.

<style>
  #loadingSpinner {display:none;};
</style>
<!--Add buttons to initiate auth sequence and sign out-->
<button id="authorize_button" style="display: none;" class="button">Authorize Google Slides</button>
<button id="create_button" onclick="copyAndMergePresso()" class="button" style="display: none;">Build Google Slides</button>

<pre id="content" style="white-space: pre-wrap;font-family:georgia;font-size:1.1em;"></pre>
<pre id="result" style="white-space: pre-wrap;font-family:georgia;font-size:1.1em;"></pre>
<button id="reload_button" onclick="reloadPage()" class="button alert" style="display: none;">Reload Page</button>

<img src="/images/ajax-loaders/small-black-circle.gif" id="loadingSpinner">
<script type="text/javascript">
  // Client ID and API key from the Developer Console
  var CLIENT_ID = 'XXX';
  var API_KEY = 'XXX';

  // Array of API discovery doc URLs for APIs used by the quickstart
  var DISCOVERY_DOCS = ["https://slides.googleapis.com/$discovery/rest?version=v1","https://www.googleapis.com/discovery/v1/apis/drive/v3/rest"];

  // Authorization scopes required by the API; multiple scopes can be
  // included, separated by spaces.
  var SCOPES = "https://www.googleapis.com/auth/presentations https://www.googleapis.com/auth/drive";

  var authorizeButton = document.getElementById('authorize_button');
  var pressoButton = document.getElementById('create_button');
  var reloadButton = document.getElementById('reload_button');
  var spinner = document.getElementById('loadingSpinner');
  var contentBlock = document.getElementById('content');
  /**
   *  On load, called to load the auth2 library and API client library.
   */
  function handleClientLoad() {
    gapi.load('client:auth2', initClient);
  }

  /**
   *  Initializes the API client library and sets up sign-in state
   *  listeners.
   */
  function initClient() {
    gapi.client.init({
      apiKey: API_KEY,
      clientId: CLIENT_ID,
      discoveryDocs: DISCOVERY_DOCS,
      scope: SCOPES
    }).then(function () {
      // Listen for sign-in state changes.
      gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);

      // Handle the initial sign-in state.
      updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
      authorizeButton.onclick = handleAuthClick;
    }, function(error) {
      appendPre(JSON.stringify(error, null, 2));
    });
  }

  /**
   *  Called when the signed in status changes, to update the UI
   *  appropriately. After a sign-in, the API is called.
   */
  function updateSigninStatus(isSignedIn) {
    if (isSignedIn) {
      authorizeButton.style.display = 'none';
      pressoButton.style.display = 'block';
    } else {
      authorizeButton.style.display = 'block';
      pressoButton.style.display = 'none';
    }
  }

  function reloadPage() {
    document.location.reload();
  }

  /**
   *  Sign in the user upon button click.
   */
  function handleAuthClick(event) {
    gapi.auth2.getAuthInstance().signIn();
  }

  /**
   * Append a pre element to the body containing the given message
   * as its text node. Used to display the results of the API call.
   *
   * @param {string} message Text to be placed in pre element.
   */
  function appendPre(message, divid) {
    if (divid) {
      var divIdToUse = divid;
    }
    else {
      var divIdToUse = 'content';
    }
    var pre = document.getElementById(divIdToUse);
    var textContent = document.createTextNode(message + '\n');
    pre.appendChild(textContent);
  }

  function copyAndMergePresso() {
    pressoButton.style.display = 'none';
    spinner.style.display = 'block';
    // Duplicate the template presentation using the Drive API.
    var templatePresentationId = '18NHbPMsNOlF0MDEsyyMegeEQxincL1ykF_ipqx8JL5Q';
    var copyTitle = 'Sheep Farming';
    appendPre('I\'m taking a few moments to create the presentation "' + copyTitle + '" for you in your Google Drive.');
    appendPre('In the meantime, please do not leave this page.');
    gapi.client.drive.files.copy({
      fileId: templatePresentationId,
      resource: {
        name: copyTitle
      }
    }).then((driveResponse) => {
      var presentationCopyId = driveResponse.result.id;
      // Create the image merge (replaceAllShapesWithImage) requests.
      var requests = [{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{ta-title}}"},"replaceText":"Sheep Farming"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{ta-date}}"},"replaceText":"14 February 2020"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{ta-creator}}"},"replaceText":"Edward Chanter"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{ta-creator-org}}"},"replaceText":"Collaborative Connections Ltd."}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{search_query}}"},"replaceText":"sheep OR mutton OR lamb"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{33-text}}"},"replaceText":"Future vantage points on emerging commercial changes"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{total_forecasts}}"},"replaceText":"176 forecasts"}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{ta-image}}"},"replaceMethod":"CENTER_CROP","imageUrl":"https://pixabay.com/get/57e8d7414b51ab14f6da8c7dda79367c153cdde65a506c4870277ad3974dc45ab8_1280.jpg"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{questions}}"},"replaceText":"Why not create sheep or cows that secrete medically useful compounds in their milk, such as the blood‑clotting factors absent in haemophiliacs?"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{17-title}}"},"replaceText":"Driving Forces"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{17-notes}}"},"replaceText":"know the global changes that will affect us all"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{17-section}}"},"replaceText":"Driving Forces"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{17-forecast}}"},"replaceText":"If average seasonal conditions are realised saleyard prices for cattle and lamb are expected to be supported as Australian producers rebuild herds and flocks."}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{17-tooltip}}"},"replaceText":"Know the global changes that will affect us all"}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{17-image}}"},"replaceMethod":"CENTER_INSIDE","imageUrl":"https://demo.shapingtomorrow.com/images/metrics/8219089/17.png"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{9-title}}"},"replaceText":"Trends"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{9-notes}}"},"replaceText":"see the trends in which your interest is developing or changing"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{9-section}}"},"replaceText":"Directions"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{9-forecast}}"},"replaceText":"In 2019-20 Australian live sheep exports are forecast to be largely unchanged from the disrupted levels of 2018-19."}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{9-tooltip}}"},"replaceText":"See the trends in which your interest is developing or changing"}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{9-image}}"},"replaceMethod":"CENTER_INSIDE","imageUrl":"https://demo.shapingtomorrow.com/images/metrics/8219089/9.png"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{10-title}}"},"replaceText":"Causes"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{10-notes}}"},"replaceText":"understand what's driving what"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{10-section}}"},"replaceText":"Directions"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{10-forecast}}"},"replaceText":"Tariffs imposed in a no-deal situation could account for around 50 percent of the price of UK sheep meat, making it uncompetitive in the EU market, something that could cause the selling price to fall in the UK by as much as 25 percent."}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{10-tooltip}}"},"replaceText":"Understand what's driving what"}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{10-image}}"},"replaceMethod":"CENTER_INSIDE","imageUrl":"https://demo.shapingtomorrow.com/images/metrics/8219089/10.png"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{11-title}}"},"replaceText":"Consequences"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{11-notes}}"},"replaceText":"discover likely outcomes and effects"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{11-section}}"},"replaceText":"Directions"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{11-forecast}}"},"replaceText":"If the average person on Earth swapped out 30 percent of the beef, lamb and goat meat they eat in favor of plant-based options, it could achieve half the reductions in greenhouse gas emissions from agriculture necessary by 2050."}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{11-tooltip}}"},"replaceText":"Discover likely outcomes and effects"}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{11-image}}"},"replaceMethod":"CENTER_INSIDE","imageUrl":"https://demo.shapingtomorrow.com/images/metrics/8219089/11.png"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{12-title}}"},"replaceText":"Solutions"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{12-notes}}"},"replaceText":"know how others are tackling issues with this topic"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{12-section}}"},"replaceText":"Directions"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{12-forecast}}"},"replaceText":"An online risk forecast could help UK sheep farmers assess the risk of outbreaks of the Nematodirus parasite in their lambs and take action before it is too late."}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{12-tooltip}}"},"replaceText":"Know how others are tackling issues with this topic"}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{12-image}}"},"replaceMethod":"CENTER_INSIDE","imageUrl":"https://demo.shapingtomorrow.com/images/metrics/8219089/12.png"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{7-title}}"},"replaceText":"Weak"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{7-notes}}"},"replaceText":"explore new discoveries, inventions and ideas"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{7-section}}"},"replaceText":"Cycles"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{7-forecast}}"},"replaceText":"World demand growth will be led by poultry and beef with weaker demand growth for pork and sheep meat."}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{7-tooltip}}"},"replaceText":"Explore new discoveries, inventions and ideas"}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{7-image}}"},"replaceMethod":"CENTER_INSIDE","imageUrl":"https://demo.shapingtomorrow.com/images/metrics/8219089/7.png"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{3-title}}"},"replaceText":"Emerging"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{3-notes}}"},"replaceText":"notice what’s becoming apparent or prominent"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{3-section}}"},"replaceText":"Cycles"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{3-forecast}}"},"replaceText":"An exotic or emergent disease such as foot-and-mouth or sheep and goat pox could affect flocks in NSW or elsewhere in Australia with sudden dramatic effects on market access for wool and sheepmeat nationally."}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{3-tooltip}}"},"replaceText":"Notice what’s becoming apparent or prominent"}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{3-image}}"},"replaceMethod":"CENTER_INSIDE","imageUrl":"https://demo.shapingtomorrow.com/images/metrics/8219089/3.png"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{4-title}}"},"replaceText":"Maturing"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{4-notes}}"},"replaceText":"contemplate future development, growth and completion"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{4-section}}"},"replaceText":"Cycles"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{4-forecast}}"},"replaceText":""}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{4-tooltip}}"},"replaceText":"Contemplate future development, growth and completion"}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{4-image}}"},"replaceMethod":"CENTER_INSIDE","imageUrl":"https://demo.shapingtomorrow.com/images/metrics/8219089/4.png"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{5-title}}"},"replaceText":"Declining"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{5-notes}}"},"replaceText":"explore what’s deteriorating, failing or collapsing"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{5-section}}"},"replaceText":"Cycles"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{5-forecast}}"},"replaceText":"In 2019-20 Australian live sheep exports are forecast to be largely unchanged from the disrupted levels of 2018-19."}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{5-tooltip}}"},"replaceText":"Explore what’s deteriorating, failing or collapsing"}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{5-image}}"},"replaceMethod":"CENTER_INSIDE","imageUrl":"https://demo.shapingtomorrow.com/images/metrics/8219089/5.png"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{1-title}}"},"replaceText":"Warnings"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{1-notes}}"},"replaceText":"take heed of alerts, cautions and forewarning"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{1-section}}"},"replaceText":"Signals"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{1-forecast}}"},"replaceText":"Market data and analysis is critical to give confidence that the global demand for sheepmeat is not simply cyclical but an enduring shift Sheep are valuable so there are loud demands to protect them from predation and biosecurity threats."}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{1-tooltip}}"},"replaceText":"Take heed of alerts, cautions and forewarning"}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{1-image}}"},"replaceMethod":"CENTER_INSIDE","imageUrl":"https://demo.shapingtomorrow.com/images/metrics/8219089/1.png"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{14-title}}"},"replaceText":"Constraints"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{14-notes}}"},"replaceText":"reflect on what is restricted, compelled or avoided"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{14-section}}"},"replaceText":"Limits"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{14-forecast}}"},"replaceText":"Lamb remains one of Australia's favourite proteins and has a unique role in the national diet: Further pricing pressure, due to forecast supply constraints and ongong strong international demand, will likely see Australia's per capita consumption continue to dip in the coming years."}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{14-tooltip}}"},"replaceText":"Reflect on what is restricted, compelled or avoided"}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{14-image}}"},"replaceMethod":"CENTER_INSIDE","imageUrl":"https://demo.shapingtomorrow.com/images/metrics/8219089/14.png"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{15-title}}"},"replaceText":"Dilemmas"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{15-notes}}"},"replaceText":"consider situations involving difficult choices"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{15-section}}"},"replaceText":"Limits"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{15-forecast}}"},"replaceText":""}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{15-tooltip}}"},"replaceText":"Consider situations involving difficult choices"}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{15-image}}"},"replaceMethod":"CENTER_INSIDE","imageUrl":"https://demo.shapingtomorrow.com/images/metrics/8219089/15.png"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{2-title}}"},"replaceText":"Bubbles"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{2-notes}}"},"replaceText":"observe ballooning and disillusionment"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{2-section}}"},"replaceText":"Signals"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{2-forecast}}"},"replaceText":""}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{2-tooltip}}"},"replaceText":"Observe ballooning and disillusionment"}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{2-image}}"},"replaceMethod":"CENTER_INSIDE","imageUrl":"https://demo.shapingtomorrow.com/images/metrics/8219089/2.png"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{6-title}}"},"replaceText":"Inflections"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{6-notes}}"},"replaceText":"give thought to potential turning points"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{6-section}}"},"replaceText":"Signals"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{6-forecast}}"},"replaceText":""}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{6-tooltip}}"},"replaceText":"Give thought to potential turning points"}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{6-image}}"},"replaceMethod":"CENTER_INSIDE","imageUrl":"https://demo.shapingtomorrow.com/images/metrics/8219089/6.png"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{8-title}}"},"replaceText":"Shocks"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{8-notes}}"},"replaceText":"eyeball potential surprises, wildcards, traumas"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{8-section}}"},"replaceText":"Signals"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{8-forecast}}"},"replaceText":"An exotic or emergent disease such as foot-and-mouth or sheep and goat pox could affect flocks in NSW or elsewhere in Australia with sudden dramatic effects on market access for wool and sheepmeat nationally."}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{8-tooltip}}"},"replaceText":"Eyeball potential surprises, wildcards, traumas"}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{8-image}}"},"replaceMethod":"CENTER_INSIDE","imageUrl":"https://demo.shapingtomorrow.com/images/metrics/8219089/8.png"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{16-title}}"},"replaceText":"Outcries"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{16-notes}}"},"replaceText":"understand what's testing people's patience"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{16-section}}"},"replaceText":"Limits"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{16-forecast}}"},"replaceText":""}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{16-tooltip}}"},"replaceText":"Understand what's testing people's patience"}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{16-image}}"},"replaceMethod":"CENTER_INSIDE","imageUrl":"https://demo.shapingtomorrow.com/images/metrics/8219089/16.png"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{13-title}}"},"replaceText":"Extremes"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{13-notes}}"},"replaceText":"investigate what’s deteriorating, failing or collapsing"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{13-section}}"},"replaceText":"Limits"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{13-forecast}}"},"replaceText":"Researchers expect to demonstrate that an artificial placenta can simulate the intrauterine environment and support a fetal lamb from extreme prematurity to normal newborn physiology."}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{13-tooltip}}"},"replaceText":"Investigate what’s deteriorating, failing or collapsing"}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{13-image}}"},"replaceMethod":"CENTER_INSIDE","imageUrl":"https://demo.shapingtomorrow.com/images/metrics/8219089/13.png"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{18-title}}"},"replaceText":"Cloud"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{18-notes}}"},"replaceText":"From 2020 - 2070, the top 5 topics underpinning the future of this topic are consumption, food, farming, healthcare and law at a 95% confidence level. The most trending topics are consumption, animal and food in the year 2020, 2021 and 2050 respectively"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{18-section}}"},"replaceText":"System"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{18-forecast}}"},"replaceText":"If average seasonal conditions are realised saleyard prices for cattle and lamb are expected to be supported as Australian producers rebuild herds and flocks."}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{18-tooltip}}"},"replaceText":""}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{18-image}}"},"replaceMethod":"CENTER_INSIDE","imageUrl":"https://demo.shapingtomorrow.com/images/metrics/8219089/18.png"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{19-title}}"},"replaceText":"Map"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{19-section}}"},"replaceText":"System"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{19-forecast}}"},"replaceText":"If average seasonal conditions are realised saleyard prices for cattle and lamb are expected to be supported as Australian producers rebuild herds and flocks."}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{19-tooltip}}"},"replaceText":""}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{19-image}}"},"replaceMethod":"CENTER_INSIDE","imageUrl":"https://demo.shapingtomorrow.com/images/metrics/8219089/19.png"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{22-title}}"},"replaceText":"Sources"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{22-section}}"},"replaceText":"System"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{22-forecast}}"},"replaceText":"If average seasonal conditions are realised saleyard prices for cattle and lamb are expected to be supported as Australian producers rebuild herds and flocks."}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{22-tooltip}}"},"replaceText":""}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{22-image}}"},"replaceMethod":"CENTER_INSIDE","imageUrl":"https://demo.shapingtomorrow.com/images/metrics/8219089/22.png"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{20-title}}"},"replaceText":"Radar"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{20-notes}}"},"replaceText":"From 2020 - 2070, the top 5 topics underpinning the future of this topic are consumption, food, farming, healthcare and law at a 95% confidence level. The most trending topics are consumption, animal and food in the year 2020, 2021 and 2050 respectively"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{20-section}}"},"replaceText":"Outlooks"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{20-forecast}}"},"replaceText":"If average seasonal conditions are realised saleyard prices for cattle and lamb are expected to be supported as Australian producers rebuild herds and flocks."}}];

      // Execute the requests for this presentation.
      gapi.client.slides.presentations.batchUpdate({
        presentationId: presentationCopyId,
        requests: requests
      }).then((batchUpdateResponse) => {
        // appendPre('The presentation ' + copyTitle + ' is being created in your Google Drive Account.');
        pressoUrl = 'https://docs.google.com/presentation/d/' + presentationCopyId + '/edit';
        var carea = document.getElementById('result');
        var a = document.createElement('a');
        var linkText = document.createTextNode("Open Presentation");
        a.appendChild(linkText);
        a.href = pressoUrl;
        a.target = "_blank";
        a.className = "button margin-top-2";
        carea.appendChild(a);
        contentBlock.style.display = 'none';
        // appendPre(`${pressoUrl}`);
        spinner.style.display = 'none';
      }, function(error) {
        spinner.style.display = 'none';
        contentBlock.style.display = 'none';
        appendPre('I\'m sorry, Google replied to my request with an error. Please click the button below to try again, I hope Google will be more accommodating next time.', 'result');
        reloadButton.style.display = 'inline';
        // appendPre(JSON.stringify(error, null, 2), 'result');
      });
    }, function(error) {
        spinner.style.display = 'none';
        contentBlock.style.display = 'none';
        reloadButton.style.display = 'inline';
        appendPre('I\'m sorry, Google replied to my request with an error. Please click the button below to try again, I hope Google will be more accommodating next time.', 'result');
        // appendPre(JSON.stringify(error, null, 2));
      });        
  }
</script>

<script async defer src="https://apis.google.com/js/api.js"
  onload="this.onload=function(){};handleClientLoad()"
  onreadystatechange="if (this.readyState === 'complete') this.onload()">
</script>

I have also changed the code so the requests array is the bare minimum:

var requests = [{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{ta-title}}"},"replaceText":"Sheep Farming"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{ta-date}}"},"replaceText":"14 February 2020"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{ta-creator}}"},"replaceText":"Edward Chanter"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{ta-creator-org}}"},"replaceText":"Collaborative Connections Ltd."}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{search_query}}"},"replaceText":"sheep OR mutton OR lamb"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{33-text}}"},"replaceText":"Future vantage points on emerging commercial changes"}},{"replaceAllText":{"containsText":{"matchCase":true,"text":"{{total_forecasts}}"},"replaceText":"176 forecasts"}},{"replaceAllShapesWithImage":{"containsText":{"matchCase":true,"text":"{{ta-image}}"},"replaceMethod":"CENTER_CROP","imageUrl":"https://pixabay.com/get/57e8d7414b51ab14f6da8c7dda79367c153cdde65a506c4870277ad3974dc45ab8_1280.jpg"}}];

Nothing seems to work and I can't figure out why. The response I'm getting from the Google Slides API is this:

{ "error": { "code": 500, "message": "Internal error encountered.", "status": "INTERNAL" } }

As I said before, this was working all of last week and this morning until I added some additional requests. Taking the stuff I added out hasn't made a difference.

Update It isn't working consistently, I've been testing with another user and some reports work whilst others fail. Some fail for me and not him and others fail for him and not me. I'm submitting over 200 requests so I'm starting to think this is related to a quota issue but I don't understand how the quotas work.


Solution

  • Following a dialog with Google, it turns out the error was caused by a broken image URL. I was using the direct pixabay URL. Changing that to download the image and serve it from my system. solved the problem.