-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDownload time to CSV.js
42 lines (40 loc) · 1.8 KB
/
Download time to CSV.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
const myHeaders = new Headers();
const installId = "installIdHere";
const userId = "userIdHere";
const tw_key = "tw_keyHere";
const reportType = "reportTypeHere"//Other formats: excel, pdf,
const startDate = "startDateHere"// YYYYMMDD - Not required (Leave blank quotes)
const endDate = "endDateHere"// YYYYMMDD - Not required (Leave blank quotes)
const projectId = "projectIdHere"// Leave blank quotes if you are reporting on all time
const urlencoded = new URLSearchParams();
urlencoded.append("action", "Time_DownloadReport");
urlencoded.append("reportType", "csv");
urlencoded.append("startDate", startDate);
urlencoded.append("endDate", endDate);
urlencoded.append("projectId", projectId);
urlencoded.append("userId", "");
urlencoded.append("teamIds", "");
urlencoded.append("invoicedType", "all");
urlencoded.append("billableType", "all");
urlencoded.append("sortBy", "date");
urlencoded.append("sortOrder", "asc");
urlencoded.append("tagIds", "");
urlencoded.append("companyId", "0");
urlencoded.append("taskTagIds", "");
urlencoded.append("matchAllTags", "true");
urlencoded.append("projectsFromCompanyId", "0");
urlencoded.append("projectStatus", "");
urlencoded.append("onlyStarredProjects", "false");
urlencoded.append("includeArchivedProjects", "false");
urlencoded.append("selectedColumns", "date,project,whoLoggedTime,descriptionAndTags,attachedTaskList,startTime,endTime,isEntryBillable,hasEntryBeenBilled,timeTaken,hoursTaken,estimatedTime");
urlencoded.append("includeTags", "true");
const requestOptions = {
method: "POST",
headers: myHeaders,
body: urlencoded,
redirect: "follow"
};
fetch("https://tw-export.teamwork.com/?tw_i="+installId+"&tw_u="+userId+"&tw_key="+tw_key, requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));