-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreate a recurring task.js
63 lines (60 loc) · 1.86 KB
/
Create a recurring task.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//https://apidocs.teamwork.com/docs/teamwork/v1/tasks/post-tasklists-id-tasks-json
const myHeaders = new Headers();
const userName = "email address or API KEY here";
const password = "password";
const siteName = "yourSiteName"
const taskListId = "taskListIdHere"
const userId = "userIdHere"
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Basic "+btoa(userName+":"+password));
const raw = JSON.stringify({
"todo-item": {
"use-defaults": false,
"completed": false,
"content": "Repeat task every 3 days - created via API",
"tasklistId": taskListId,
"creator-id": 0,
"notify": true,
"responsible-party-id": userId,
"start-date": "",
"due-date": "20240424",//yyyymmdd
"description": "Repeat task every 3 days - created via API for research",
"priority": "",
"progress": 0,
"parentTaskId": 0,
"tagIds": "",
"everyone-must-do": false,
"predecessors": [],
"reminders": null,
"columnId": 0,
"commentFollowerIds": "-1",
"changeFollowerIds": "-1",
"grant-access-to": "",
"private": false,
"customFields": [],
"estimated-minutes": 0,
"pendingFileAttachments": [],
"updateFiles": true,
"attachments": "",
"removeOtherFiles": true,
"attachmentsCategoryIds": "",
"pendingFileAttachmentsCategoryIds": "",
"repeatOptions": {
"selecteddays": "",
"repeatEndDate": "noEndDate",
"repeatsFreq": "everyxdays",
"monthlyRepeatType": "monthDay",
"duration": "3"//Number of days between repeat tasks
}
}
});
const requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow"
};
fetch("https://"+siteName+".teamwork.com/tasklists/"+taskListId+"/tasks.json", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));