0

I need your help with the issue which is bugging me since a couple hours. I part of my code just doesn't want to run for me:

  var options = {'muteHttpExceptions': true, 'AllowAutoRedirect': true};
  var url = "https://www.auftrag.at//tenders.aspx"
  var firstResponse = UrlFetchApp.fetch(url, options);
  Logger.log(firstResponse.getContentText());
  if(firstResponse.getResponseCode() == 200){....

This always delivers the following response (Code 302):

<html><head><title>Object moved</title></head><body>
    <h2>Object moved to <a href="/tenders.aspx?AspxAutoDetectCookieSupport=1">here</a>.</h2>
    </body></html>

Can you please help me in fixing this? Thank you

  • 1
    Does this answer your question? [What Google AppsScript method is used to get the URL of a redirect?](https://stackoverflow.com/questions/27098169/what-google-appsscript-method-is-used-to-get-the-url-of-a-redirect) – Kos Sep 16 '21 at 13:58
  • Thank you for the answer, but there is still a problem After the first iteration, the redirectURL is: "/tenders.aspx?AspxAutoDetectCookieSupport=1", which makes the next iteration fail since it's not a valid URL. If I adapt the code with var nextRedirectUrl = getRedirect("https://www.auftrag.at/"+ redirectUrl); I get stuck in an endless loop – Chris B Sep 16 '21 at 14:32
  • then it looks like you deal with wrongly configured web server – Kos Sep 16 '21 at 15:19
  • I think the issue is more related to the missing Cookie Support – Chris B Sep 28 '21 at 11:22
  • still looks like web server issue, anyway Apps Script supports sending cookies same as regular headers, see https://stackoverflow.com/questions/10869932/cookie-handling-in-google-apps-script-how-to-send-cookies-in-header – Kos Sep 28 '21 at 12:14

0 Answers0