Skip to content

Commit a61b5c3

Browse files
authored
Create New task comment.js
1 parent eaaf618 commit a61b5c3

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const myHeaders = new Headers();
2+
const userName = "email address or API KEY here";
3+
const password = "password";
4+
const siteName = "yourSiteName"
5+
const taskId = "taskIdHere"
6+
const userId = "userIdHere"
7+
const notifyUserId = "notifyUserIdHere"
8+
const notifyUserHandle = "notifyUserHandleHere"//ie:@marcc
9+
myHeaders.append("Content-Type", "application/json");
10+
myHeaders.append("Authorization", "Basic "+btoa(userName+":"+password));
11+
12+
const raw = JSON.stringify({
13+
"objectId": taskId,
14+
"objectType": "task",
15+
"comment": {
16+
"body": "Adding a comment via API.\ncc "+notifyUserHandle,
17+
"author-id": userId,
18+
"content-type": "TEXT",
19+
"notify": notifyUserId,//Add empty quotes when no notification is required
20+
"notify-current-user": false,
21+
"skipNotifications": false,
22+
"remove-other-files": true,
23+
"grant-access-to": "",
24+
"private": 0,
25+
"pendingFileAttachments": [],
26+
"updateFiles": true,
27+
"fileIds": "",
28+
"attachmentsCategoryIds": "",
29+
"pendingFileAttachmentsCategoryIds": ""
30+
}
31+
});
32+
33+
const requestOptions = {
34+
method: "POST",
35+
headers: myHeaders,
36+
body: raw,
37+
redirect: "follow"
38+
};
39+
40+
fetch("https://"+siteName+".teamwork.com/tasks/"+taskId+"/comments.json", requestOptions)
41+
.then((response) => response.text())
42+
.then((result) => console.log(result))
43+
.catch((error) => console.error(error));

0 commit comments

Comments
 (0)