r/GoogleAppsScript • u/Puzzleheaded_Candy96 • May 08 '25
Question Need help with batch requests.
So, I created this spreadsheet, a roster database that automatically updates people's names with their profile names through their profile ID, so if they change their profile name, it happens automatically. The script works, but now, with a lot more names added to the sheet, the API calls hang, and some of the names don't ever make it through and update, getting stuck on "Fetching user."
I'm trying to learn batch requests, and I don't know if I can fix this efficiency problem with how I already have this sheet set up.
I'm new to this.
Sheet: https://docs.google.com/spreadsheets/d/1miJ14VZiPYX3Cz2Fa7BsfdoSL_Rbh-WMqs_av8_sdbM/edit?usp=sharing
API Script: https://gyazo.com/c303e9cd8c87d62c943a18493aac8363
I would greatly appreciate any help.
1
u/marcnotmark925 May 08 '25
What do the API docs say about batch requests?
1
u/WicketTheQuerent May 08 '25
Share code as text, not as an image.
1
u/Current-Leather2784 May 09 '25
Does your API support batching? If so - you could try the script i sent via chat:
Next Steps:
"https://api.example.com/profiles"with the actual API endpoint you’re using.batchSizeto optimize performance based on API limits.1
u/Mudita_Tsundoko May 14 '25
I'd look into making a series of bulk requests if possible and then performing a look up against the data locally using your formulas/ a vlookup as opposed to having each cell make their own api request as you're likely hitting the rate limit of the google api, as opposed to the rate limit of the resource you're trying to query.
https://developers.google.com/workspace/sheets/api/limits#increase