问题
First I created a Task using below link: https://mail.google.com/tasks/canvas
Then I marked it as Completed. When I checked the API Response for the same using: Services > Tasks API v1 > tasks.tasks.list [Returns all tasks in the specified task list.] I was able to view the updates & found the task i marked as complete.
However when I did the same using New interface (theme) from GMail, I found that the task I updated with completion was not at all there in above API Response.
Thus Google Tasks API does not give update about Task completion when New Gmail Theme used. Is there anything I missed or is it bug from Google Task API with Newly introduced theme?
回答1:
I was held up by this same thing this week. but I just figured it out using the "Try this API" feature on https://developers.google.com/tasks/v1/reference/tasks/list which I got to show me my completed tasks. After looking at how their code told tasks.tasks.list that they wanted to be given the completed and hidden items (both flags were needed) I played around with my code and learned from error messages that after giving the tasklist ID, I could add a JavaScript object literal, so I copied part of object literal from the code of the "Try this API" and the following worked.
var tasks = Tasks.Tasks.list( taskListId, { showCompleted: true, showHidden: true } );
if (tasks.items) {
for (var i = 0; i < tasks.items.length; i++) {
var task = tasks.items[i];
Logger.log('Task with title "%s" and notes "%s" and status "%s" was found ' ,
task.title, task.notes, task.status );
}
}
来源:https://stackoverflow.com/questions/52179087/google-tasks-api-does-not-give-update-about-task-completion-when-new-gmail-theme