I tried to fetch same URL via google script & Oauth playground.....In playground it works properly and give status 200 OK..But with google script , it gives invalid argument error......Give me some suggestion
URL='https://sites.google.com/feeds/content/domainname/siteName/-/template|-template '
Code :
var base = 'https://sites.google.com/feeds/';
var fetchArgs = googleOAuth_('sites', base);
fetchArgs.method = 'GET';
var url=https://sites.google.com/feeds/content/domainname/siteName/-/template|-template'
var resultOfSiteWebPages=UrlFetchApp.fetch(url,fetchArgs)
Gives error in UrlFetch
This is most likely a encoding issue. The oAuth playground probably encodes the url for you and UrlFetch
doesn't. Try this:
var resultOfSiteWebPages = UrlFetchApp.fetch(encodeURI(url), fetchArgs);