Created
March 27, 2024 12:07
-
-
Save marcosleal-prd/39020ea9cbdeadaf80493c7661dc462d to your computer and use it in GitHub Desktop.
Enable import range App Scripts
This file contains 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 enableImportRangePermission(ssId, donorId) { | |
console.log(`Addind ImportRangePermission for ${ssId}`) | |
const url = `https://docs.google.com/spreadsheets/d/${ssId}/externaldata/addimportrangepermissions?donorDocId=${donorId}` | |
const token = ScriptApp.getOAuthToken() | |
const params = { | |
method: 'post', | |
headers: { | |
Authorization: 'Bearer ' + token, | |
}, | |
muteHttpExceptions: true | |
} | |
const response = UrlFetchApp.fetch(url, params) | |
if (response.getResponseCode() < 200 || response.getResponseCode() > 299) { | |
console.log(`[IMPORT_RANGE_ERROR] Error during feasibility enable import range permission, Feasibility ID: ${dt.id}`) | |
throw new Error(`[IMPORT_RANGE_ERROR] Request error (${dt.callbackUrl}): ${response.getContentText()}`) | |
} | |
console.log(`Permission added to ${ssId} (donor: ${donorId})`) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment