'www.mysite.com/mySecretKey1' redirects to 'www.othersite.com/mySecretKey2'
in G.AppsScript:
var response = UrlFetchApp.fetch("https://www.mysite.com/mySecretKey1");
var headerString = response.getAllHeaders().toSource();
Logger.log(headerString);
//string 'www.othersite.com.my/SecretKey2' is not present in log.
How would the script discover the URL address that it is redirected to (i.e. the string 'www.othersite.com/mySecretKey2')?
UPDATE: More generally, how would the script discover the URL address from response
?
There is a native support in UrlFetchApp to follow redirects. You should try to set:
In the options you providing to UrlFetchApp. Something like that: