Where do I find the tasklist ID

2019-07-29 07:06发布

问题:

I am trying to create tasks in a tasklist from the google app script editor. Looks like I need the id of the tasklist to be able to add the task.

Problem is I can figure out where ti find the tasklist ID

回答1:

If you want to retrieve the tasklist IDs using Google Apps Script, how about this sample script?

In order to use the sample script, before you run the script, please enable Tasks API at Advanced Google Services and API console as follows.

Enable Tasks API at Advanced Google Services

  • On script editor
    • Resources -> Advanced Google Services
    • Turn on Tasks API v1

Enable Tasks API at API console

  • On script editor
    • Resources -> Cloud Platform project
    • View API console
    • At Getting started, click "Explore and enable APIs".
    • At left side, click Library.
    • At "Search for APIs & services", input "Tasks API". And click "Tasks API".
    • Click Enable button.
    • If API has already been enabled, please don't turn off.

Sample script:

After Tasks API was enabled, please run the following script.

function myFunction() {
  var taskLists = Tasks.Tasklists.list().getItems();
  var res = taskLists.map(function(list) {
    return {
      taskListId: list.getId(),
      listName: list.getTitle(),
    };
  });
  Logger.log(res)
}

Reference:

  • Google Tasks API

If this was not the result you want, I apologize.