Why does SitesApp.getSites(myDomain) not work?

2019-03-06 19:47发布

I'm currently playing around with Google Apps Script and can't get the following snippet to work. enter image description here

The error message is: the requested resource was not found.
enter image description here
I also tested the undocumented method which I found here: Need to list all the sites under a google domain using Google Apps Script

    var mySites = SitesApp.getAllSites(myDomain, 1, 10);

but I get the same error. For the complete example, see below. Thank you in advance.

function view() {
  var myDomain = 'example.com';

  // this works
  var mySite = SitesApp.getSite(myDomain);
  Logger.log('title=' + mySite.getTitle() + '\n' + 'name=' + mySite.getName());

  // this works, too
  var myPages = mySite.getAllDescendants();
  for (i in myPages) {
    Logger.log('page=' + myPages[i].getTitle());
  }  

  //this does not work, error: the requested ressource was not found
  var mySites = SitesApp.getSites(myDomain);

  // this also does not work, same error
  var mySites = SitesApp.getAllSites(myDomain, 1, 10);
}

EDIT 1: I tested with 3 different browsers on Windows 7: Firefox Nightly, Google Chrome and Opera.
EDIT 2: Same error on Samsung Galaxy Tab 10.1N with Android 3.2 and Firefox browser.

3条回答
再贱就再见
2楼-- · 2019-03-06 20:17

You'll get that error when the service can't find the domain or you don't have access to it. Please ensure that the domain matches exactly, and doesn't start with "www.", etc.

查看更多
女痞
3楼-- · 2019-03-06 20:27

I think you should use:

  var mySite = 'https://sites.google.com/site/name_of_the_site';
  var site = SitesApp.getSiteByUrl(mySite);
查看更多
三岁会撩人
4楼-- · 2019-03-06 20:32

Please try the below line

for(i=0;i<=80;i++) { 

Logger.log('title=' + mySite[i].getTitle() + '\n' + 'name=' + mySite[i].getName());

 }
查看更多
登录 后发表回答