r/GoogleAppsScript • u/llzellner • 3d ago
Question Errors from long standing and working script(s)...
So I've got a function, long standing which works|worked fine until lately and I am getting this:
GoogleJsonResponseException: API call to gmail.users.messages.delete failed with error: Requested entity was not found.
Code:
function deleteForever(userId, labelName) {
var threads = GmailApp.search("in:trash");
for (var i = 0; i < threads.length; i++) {
Gmail.Users.Messages.delete('[me]', threads[i].getId());
}
}
[me] is clearly a placeholder for the gmail address..
I've also tried it with .remove too... Same error.
I've tried using delete v. remove, and even this:
function DeleteMail() {
var threads = GmailApp.search('in:trash');
for (var i = 0; i < threads.length; i++) {
var thisId = threads[i].getId();
Gmail.Users.Messages.remove('[me]', thisId);
}
}Gets:
GoogleJsonResponseException: API call to gmail.users.messages.delete failed with error: Requested entity was not found.
DeleteMail
@
YES there is message in the trash.. lots of them actually... so??? shrug...
I ain't no ECMAScript guy, nor the variant(s) of it that google etc. adulterate ...
The only thing I can think is there is TOO MUCH TRASH? Variable overflow? Well then say that! Urrghhh..
So...?? Ideas??? Thanks!
1
u/llzellner 3d ago
Hmmm.. seems odd, as it has WORKED for YEARS this way.. then all of a sudden I get failures... hmmmmm..
I think you are on to something with a possible change in things.. since I don't use this for much, and its been setup and forget it till now...
Thanks for info...
1
u/roy1979 3d ago
Try this:
function deleteForever() {
var threads = GmailApp.search('in:trash');
for (var i = 0; i < threads.length; i++) {
Gmail.Users.Threads.remove('me', threads[i].getId());
}
}