Skip to content

Instantly share code, notes, and snippets.

@baileymatthewr
Last active May 25, 2024 04:36
Show Gist options
  • Save baileymatthewr/197179eb2b9340f2a47a9b9be019c214 to your computer and use it in GitHub Desktop.
Save baileymatthewr/197179eb2b9340f2a47a9b9be019c214 to your computer and use it in GitHub Desktop.
Google Script URL Fetch with Credentials for Persistent URLs
function fetchMethod()
{
var options = {};
// This code uses a "headers" option in order to pass in credentials
options.headers = {"Authorization": "Basic " + Utilities.base64Encode(username + ":" + password)};
// The code below logs the output of the following Persistent URL.
var response = UrlFetchApp.fetch("https://www.doba.com/retailer-export/get/type/product/tag/*", options);
Logger.log(response.getContentText()); //Log the download in the Google Script Logger
DriveApp.createFile("file_name_of_your_choice", response); //Download the file to Google Drive.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment