-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEdit a User (update working hours).js
57 lines (54 loc) · 1.25 KB
/
Edit a User (update working hours).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
const myHeaders = new Headers();
const userName = "email address or API KEY here";
const password = "password";
const siteName = "yourSiteName"
const userId = "userIdhere"
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Basic "+btoa(userName+":"+password));
const raw = JSON.stringify({
"person": {
"lengthOfDay": 7,
"workingHours": {
"entries": [
{
"weekday": "sunday",
"taskHours": 0
},
{
"weekday": "monday",
"taskHours": 7
},
{
"weekday": "tuesday",
"taskHours": 7
},
{
"weekday": "wednesday",
"taskHours": 7
},
{
"weekday": "thursday",
"taskHours": 7
},
{
"weekday": "friday",
"taskHours": 7
},
{
"weekday": "saturday",
"taskHours": 0
}
]
}
}
});
const requestOptions = {
method: "PUT",
headers: myHeaders,
body: raw,
redirect: "follow"
};
fetch("https://"+siteName+".teamwork.com/people/"+userId+".json", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));