I have a database of 1000 events. Each event has an entity code 1..1000. Each event may or may not have an associated .jpg file, which is stored on a remote server. If it exists, it is named nnnn.jpg, so event 467 has 0467.jpg .
I need to test, frequently, whether each event has its .jpg on that server or not.
If the .jpg exists, it returns a response code of 200; if it does not, some other response code is returned.
I test this in a loop:
resp1 = UrlFetchApp.fetch(urt, {muteHttpExceptions: true, followRedirects: false});
resp2 = resp1.getResponseCode();
where urt is the full path including each file name 0001.jpg to 1000.jpg
This takes a great deal of processing time, which can be shortened by skipping items where we already know the answer, but still the processing time is very long and often aborts, presumably due to over-use.
I have looked for a solution involving fetchAll() but I do not quite understand how. If I had an array 1..1000 of response codes, the rest of the processing would be easy.
Apologies if the request offends or if it has already been answered, but I have searched and cannot find. Thank you.
resp1 = UrlFetchApp.fetchAll({muteHttpExceptions: true, followRedirects: false}).getResponseCode();
fails on Exception: The parameters ((class)) don’t match the method signature for UrlFetchApp.fetchAll. error
Peter Buckley Hill is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.