Web Services Definition » History » Version 20
Kurt Gerber, 13 Dec 2018 16:47
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 | 12 | Kurt Gerber | 1. Whithout the 'edition' endpoint, it should response 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 | 17 | 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 | * After a successfull authentification, the server sends a 'sessionid'. This sessionid 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 | {"sessionid":"09249249243729342123ad232dc"} |
||
45 | </code></pre> |
||
46 | 1 | Kurt Gerber | |
47 | 15 | Kurt Gerber | |
48 | 1 | Kurt Gerber | |
49 | 19 | Kurt Gerber | |
50 | 17 | Kurt Gerber | h3. 2. Upload endpoint |
51 | 1 | Kurt Gerber | |
52 | |||
53 | 17 | Kurt Gerber | *Endpoint:* @/api/v2/create/<configuration>/<edition>@ |
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 | * @sessionid: 6xn26rwsy0r0k2yn5bsoq2qiyssg9mrs@ |
||
62 | * @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 | 3. endpoint image/file upload |
||
75 | |||
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 | 20 | Kurt Gerber | |
95 | The value of the key "uid" is what is then really stored in the 'image' key field of the corresponding questionnaire. |