Web Services Definition » History » Version 27
Kurt Gerber, 17 Dec 2018 09:17
1 | 10 | Kurt Gerber | h1. API / Web Services Requirements |
---|---|---|---|
2 | 2 | Kurt Gerber | |
3 | h2. Request services |
||
4 | 11 | Kurt Gerber | |
5 | 1 | Kurt Gerber | The existing API is documented here: https://qcat.readthedocs.io/en/latest/api/docs.html |
6 | |||
7 | 12 | Kurt Gerber | h3. Required missing request services: |
8 | 10 | Kurt Gerber | |
9 | 12 | Kurt Gerber | * There is an endpoint to get the configuration for a specific questionnaire and edition: https://https://qcat.wocat.net/en/api/v2/configuration/technologies/2018/ |
10 | 10 | Kurt Gerber | |
11 | 25 | Kurt Gerber | 1. Whithout the 'edition' endpoint, it should respond with an array of available editions. Now it answers with a 'Not found' html page. |
12 | 10 | Kurt Gerber | |
13 | 12 | Kurt Gerber | 2. Without the specific configuration endpoint (like 'technologies'), the response should be an array of available configurations. Now it answers with a 'Not found' html page. |
14 | |||
15 | |||
16 | 10 | Kurt Gerber | h2. Requirements for services to add / update cases |
17 | 12 | Kurt Gerber | |
18 | 15 | Kurt Gerber | The following new webservice endpoints must be developed. |
19 | 1 | Kurt Gerber | |
20 | 26 | Kurt Gerber | h3. 1. Authentification endpoint |
21 | 12 | Kurt Gerber | |
22 | To upload a case, a user has to authenticate himself. Therefore an authentification endpoint is needed. |
||
23 | 1 | Kurt Gerber | |
24 | 13 | Kurt Gerber | %{background:#F2D5A0} The existing authorization token serves only as authorization to access the API. |
25 | 15 | Kurt Gerber | The token is application based and always the same for a certain application, independently of the user working with the application.% |
26 | 1 | Kurt Gerber | |
27 | 17 | Kurt Gerber | * The user has to authenticate before any data is uploaded or non-public downloaded. |
28 | 27 | Kurt Gerber | * After a successfull authentification, the server sends a token. This token has to be added to the request header for any subsequent POST request. Should work a bit as on the web UI with the sessionid in the cookie. |
29 | * Limitations on client side? (to discuss) |
||
30 | 1 | Kurt Gerber | |
31 | |||
32 | 17 | Kurt Gerber | *Endpoint:* _/api/v2/user-token/_ |
33 | |||
34 | 1 | Kurt Gerber | *Allowed method:* _POST_ |
35 | |||
36 | 16 | Kurt Gerber | *Post data:* |
37 | 15 | Kurt Gerber | |
38 | 17 | Kurt Gerber | * @username@: The username of a WOCAT account |
39 | * @password@: The password of the corresponding WOCAT account |
||
40 | 15 | Kurt Gerber | |
41 | |||
42 | 17 | Kurt Gerber | *Response:* |
43 | 19 | Kurt Gerber | <pre><code class="json"> |
44 | 27 | Kurt Gerber | {"usertoken":"09249249243729342123ad232dc"} |
45 | 19 | Kurt Gerber | </code></pre> |
46 | 1 | Kurt Gerber | |
47 | 15 | Kurt Gerber | |
48 | 1 | Kurt Gerber | |
49 | 19 | Kurt Gerber | |
50 | 24 | Kurt Gerber | h3. 2. Endpoint to create new case |
51 | 1 | Kurt Gerber | |
52 | |||
53 | 24 | Kurt Gerber | *Endpoint:* @/api/v2/en/questionnaires/<configuration>/<edition>/create@ |
54 | 1 | Kurt Gerber | |
55 | 17 | Kurt Gerber | *Allowed method:* @POST@ |
56 | 14 | Kurt Gerber | |
57 | 17 | Kurt Gerber | *POST data:* a valid questionnaire based on the corresponding "configuration template":https://qcat.readthedocs.io/en/latest/api/v2.html#structure-of-configuration |
58 | 1 | Kurt Gerber | |
59 | 18 | Kurt Gerber | *Request Header:* |
60 | 17 | Kurt Gerber | * @Authorization: Token AUTH_TOKEN@ |
61 | 27 | Kurt Gerber | * @usertoken: <usertoken>@ |
62 | 17 | Kurt Gerber | * @Accept: application/json@ or @Accept: application/xml@ |
63 | 1 | Kurt Gerber | * @Content-Type: application/json@ or @Content-Type: application/xml@ |
64 | 19 | Kurt Gerber | |
65 | |||
66 | *Response:* |
||
67 | <pre><code class="json"> |
||
68 | {"success":"true", |
||
69 | "code": "technologies_4534" |
||
70 | } |
||
71 | 20 | Kurt Gerber | </code></pre> |
72 | 19 | Kurt Gerber | |
73 | 20 | Kurt Gerber | |
74 | 22 | Kurt Gerber | h3. 3. image/file upload |
75 | 20 | Kurt Gerber | |
76 | This should be handled the same as already done the ui version. |
||
77 | |||
78 | Adding an image uploads it directly with POST to https://qcat.wocat.net/en/upload |
||
79 | |||
80 | As response it gets a JSON like this: |
||
81 | <pre><code class="json"> |
||
82 | { |
||
83 | "success": true, |
||
84 | "uid": "cfb23a06-385a-47c5-8a94-83cae1fd90b7", |
||
85 | "interchange": [ |
||
86 | "[/upload/9d/a/9da8b521-7130-48df-ba31-549016a748e5.jpg, (default)]", |
||
87 | "[/upload/0a/3/0a3fea13-1485-4ec8-92ee-351eef561d2d.jpg, (small)]", |
||
88 | "[/upload/17/0/170251f9-a9ea-4945-a714-0beaebb7c750.jpg, (medium)]", |
||
89 | "[/upload/cf/b/cfb23a06-385a-47c5-8a94-83cae1fd90b7.jpg, (large)]" |
||
90 | ], |
||
91 | "url": "/upload/cf/b/cfb23a06-385a-47c5-8a94-83cae1fd90b7.jpg" |
||
92 | } |
||
93 | 19 | Kurt Gerber | </code></pre> |
94 | 1 | Kurt Gerber | |
95 | The value of the key "uid" is what is then really stored in the 'image' key field of the corresponding questionnaire. |
||
96 | |||
97 | |||
98 | 25 | Kurt Gerber | h3. 4. Endpoint to edit a case |
99 | |||
100 | *Endpoint:* @/api/v2/en/questionnaires/{configuration}/{edition}/edit/{identifier}@ |
||
101 | |||
102 | %{background:#F2D5A0} Opening a case in draft mode to edit has to take care of different things:% |
||
103 | * %{background:#F2D5A0}Only the newest version of a case can be edited% |
||
104 | * %{background:#F2D5A0}Only if the case is public or in draft mode% |
||
105 | |||
106 | *Open question:* %{background:#F2D5A0}Locking mechanism in the environment of apps going offline has to be discussed% |
||
107 | |||
108 | *Request header:* |
||
109 | * @Authorization: Token AUTH_TOKEN@ |
||
110 | 27 | Kurt Gerber | * @usertoken: <usertoken>@ |
111 | 25 | Kurt Gerber | * @Accept: application/json@ or @Accept: application/xml@ |
112 | * @Content-Type: application/json@ or @Content-Type: application/xml@ |
||
113 | |||
114 | *Allowed method:* @GET, POST@ |
||
115 | |||
116 | *GET:* |
||
117 | * Response would be the case in 'draft mode' |
||
118 | |||
119 | *POST:* |
||
120 | |||
121 | *POST data:* a valid, updated questionnaire based on the corresponding "configuration template":https://qcat.readthedocs.io/en/latest/api/v2.html#structure-of-configuration |
||
122 | |||
123 | *Response:* |
||
124 | <pre><code class="json"> |
||
125 | {"success":"true", |
||
126 | "code": "technologies_4534" |
||
127 | } |
||
128 | </code></pre> |
||
129 | |||
130 | |||
131 | h3. 5. Endpoint to get mydata |
||
132 | |||
133 | *Endpoint:* @/api/v2/en/questionnaires/mydata@ |
||
134 | |||
135 | *Allowed method:* @GET@ |
||
136 | |||
137 | *Request Header:* |
||
138 | * @Authorization: Token AUTH_TOKEN@ |
||
139 | 27 | Kurt Gerber | * @usertoken: <usertoken>@ |
140 | 25 | Kurt Gerber | * @Accept: application/json@ or @Accept: application/xml@ |
141 | * @Content-Type: application/json@ or @Content-Type: application/xml@ |
||
142 | |||
143 | *Response:* List of public or draft cases of which the user is the compiler |