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

Viewed 251

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?

2 Answers

i just had the same error. my script stopped working. it looks like the "ContentService.MimeType.RSS" does no longer exist. "RSS" is no longer an autocomplete option if you type that.

i changed it to the "ContentService.MimeType.TEXT". it is the closest option. i also had to make a new deployment after saving the new code.

now my script is working again.

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

Related