Skip to content

Instantly share code, notes, and snippets.

@ochilab
Created June 26, 2023 05:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ochilab/07b97476a97e533884177a408e28cba1 to your computer and use it in GitHub Desktop.
Save ochilab/07b97476a97e533884177a408e28cba1 to your computer and use it in GitHub Desktop.
GAS: Todoistから完了したタスクを取ってくる
/**
sinceから現在まですべてのタスクをとってくる
since: 取得開始する日時 (2023-06-26 というフォーマットの文字列)
**/
function todoistGetCompleteItems(since) {
const token = PropertiesService.getScriptProperties().getProperty('TODOIST_TOKEN');
const url = 'https://api.todoist.com/sync/v9/completed/get_all?since='+since+'T00:00:00';
const params = {
headers: { 'Authorization': `Bearer ${token}` }
};
const response = UrlFetchApp.fetch(url, params);
const json = response.getContentText();
const obj = JSON.parse(json);
const result = obj["items"];
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment