-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNew task comment.js
43 lines (40 loc) · 1.31 KB
/
New task comment.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
const myHeaders = new Headers();
const userName = "email address or API KEY here";
const password = "password";
const siteName = "yourSiteName"
const taskId = "taskIdHere"
const userId = "userIdHere"
const notifyUserId = "notifyUserIdHere"
const notifyUserHandle = "notifyUserHandleHere"//ie:@marcc
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Basic "+btoa(userName+":"+password));
const raw = JSON.stringify({
"objectId": taskId,
"objectType": "task",
"comment": {
"body": "Adding a comment via API.\ncc "+notifyUserHandle,
"author-id": userId,
"content-type": "TEXT",
"notify": notifyUserId,//Add empty quotes when no notification is required
"notify-current-user": false,
"skipNotifications": false,
"remove-other-files": true,
"grant-access-to": "",
"private": 0,
"pendingFileAttachments": [],
"updateFiles": true,
"fileIds": "",
"attachmentsCategoryIds": "",
"pendingFileAttachmentsCategoryIds": ""
}
});
const requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow"
};
fetch("https://"+siteName+".teamwork.com/tasks/"+taskId+"/comments.json", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));