Last active
January 2, 2017 19:26
-
-
Save tanyagupta/bcdefd4e5a3f841d8369608de8dcb8ec to your computer and use it in GitHub Desktop.
UrlFetchApp with Drive (multiple pages)
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
var all_results ={}; | |
var response = UrlFetchApp.fetch("https://www.googleapis.com/drive/v3/files?q="+mime_type,params); | |
var result=JSON.parse(response.getContentText()) ; | |
for (var i in result['files']) { | |
all_results[result['files'][i]['id']] = result['files'][i]['name']; | |
} | |
while (result['nextPageToken']) { | |
var pageToken = encodeURIComponent(result['nextPageToken']); | |
var new_call = "https://www.googleapis.com/drive/v3/files?"+"pageToken="+pageToken+"&q="+mime_type; | |
response = UrlFetchApp.fetch(new_call, params); | |
result=JSON.parse(response.getContentText()) | |
for (var i in result['files']) { | |
all_results[result['files'][i]['id']] = result['files'][i]['name']; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment