Search code examples
google-apps-scriptweb-applications

suddenly I get the error: Cannot find method setMimeType((class)) without any change


Suddenly my script get the error:

Cannot find method setMimeType((class)) (line xxx, file "Code")

It worked well for years, until this afternoon. I didn't modified it at all.

What I've done after:

  1. copied this code from google documentation:

    function doGet() {
      var feed =  UrlFetchApp.fetch('http://xkcd.com/rss.xml').getContentText();
      feed = feed.replace(
        /(<img.*?alt="(.*?)".*?>)/g,
        '$1' + new Array(10).join('<br />') + '$2');
      return ContentService.createTextOutput(feed)
        .setMimeType(ContentService.MimeType.RSS);
    }
    
  2. pasted it into a new script

  3. given it the proper authorizations

  4. run it

It was ok.

Then:

  1. renamed the doGet() function into doGet1() in my broken script
  2. pasted the example doGet() function code
  3. run my script (doGet function)

I obtained the same error:

Cannot find method setMimeType((class)) (line xxx, file "Code")

What could have happened?


Solution

  • Trying to debug my script, a message informed me that my project uses an old Apps Script runtime, and that in order to execute debug I have to upgrade to Javascript V8 engine. After doing that, everything went back to normal. I attach a screenshot (from a different script, in Italian language).

    enter image description here