Last active
May 25, 2024 04:36
-
-
Save baileymatthewr/197179eb2b9340f2a47a9b9be019c214 to your computer and use it in GitHub Desktop.
Google Script URL Fetch with Credentials for Persistent URLs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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