This repository has been archived by the owner on Mar 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_calls.py
69 lines (65 loc) · 1.83 KB
/
api_calls.py
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
64
65
66
67
68
69
import requests
# get all visible projects
response = requests.get(
'https://demo-stable.kimai.org/api/projects',
params={
'visible': '1' #values: 1=visible, 2=hidden, 3=both (default; 1)
},
headers={
'Accept': 'application/json',
'X-AUTH-USER': 'susan_super',
'X-AUTH-TOKEN': 'api_kitten',
},
)
if response and response.status_code == 200:
projects = response.json()
print(projects)
# get all users (with id and name)
response = requests.get(
'https://demo-stable.kimai.org/api/users',
params={
'visible': '1' #values: 1=visible, 2=hidden, 3=both (default; 1)
},
headers={
'Accept': 'application/json',
'X-AUTH-USER': 'susan_super',
'X-AUTH-TOKEN': 'api_kitten',
},
)
if response and response.status_code == 200:
users = response.json()
print(users)
#get all activities
response = requests.get(
'https://demo-stable.kimai.org/api/activities',
params={
'visible': '1' #values: 1=visible, 2=hidden, 3=both (default; 1)
},
headers={
'Accept': 'application/json',
'X-AUTH-USER': 'susan_super',
'X-AUTH-TOKEN': 'api_kitten',
},
)
if response and response.status_code == 200:
activities = response.json()
print(activities)
#post (create) new timesheet for another user
response = requests.post('https://demo-stable.kimai.org/api/timesheets',
data={
"begin": "2020-04-23T15:00:23",
"end": "2020-04-23T15:04:23",
"project": 199,
"activity": 2490,
"description": "asdf 22 api python",
"tags": "asdf 22",
},
headers={
'Accept': 'application/json',
'X-AUTH-USER': 'susan_super',
'X-AUTH-TOKEN': 'api_kitten',
},
)
if response and response.status_code == 200:
timesheet = response.json()
print(timesheet)