作为一个更大项目的一部分,我正在使用script.google.com编辑器尝试从列表中删除任务,但我一直收到一个错误,上面写着
API call to tasks.tasks.delete failed with error: Task not found.
以下是我创建的从列表中删除任务的函数:
function deleteTask(){
taskid = 'ajM2UDZIZGctaXJnOTJjZg';
tasklist = 'MDk2MzE1ODgxNDkyNDE1NTI3MDA6MDow';
try {
// Call insert method with taskDetails and taskListId to insert Task to specified tasklist.
Tasks.Tasks.remove(taskid, taskListId);
// Print the Task ID of created task.
console.log('Task with ID "%s" was deleted.', taskid);
} catch (err) {
// TODO (developer) - Handle exception from Tasks.move() of Task API
console.log('Failed to move task with an error: %s', err.message);
}
}
有趣的是,当我使用
https://developers.google.com/tasks/reference/rest/v1/tasks/delete
它有效
able to remove tasks from developer.google.com
你知道我可能做错了什么吗?我知道这可能很简单,我还是javascript的新手,这很令人沮丧。如有任何帮助,我们将不胜感激
我已经尝试使用以下代码来获取父列表ID和taskID。这似乎很有效
const taskLists = Tasks.Tasklists.list();
// If taskLists are available then print all tasklists.
if (!taskLists.items) {
console.log('No task lists found.');
return;
}
// Print the tasklist title and tasklist id.
for (let i = 0; i < taskLists.items.length; i++) {
const taskList = taskLists.items[i];
//console.log('Task list with title Tasks" and ID "%s" was found.', taskList.title, taskList.id);
console.log(taskList);
}