@@ -15,25 +15,28 @@ vendor/bin/drush pm:enable os2forms_rest_api
1515We use [ Key auth] ( https://www.drupal.org/project/key_auth ) for authenticating
1616api users.
1717
18- A user can access the Webforrm REST API if
18+ A user can access the Webform REST API if
1919
20- 1 . it has the “OS2Form REST API user” (` os2forms_rest_api_user ` ) role and
21- 2 . has a generated key (User > Edit > Key authentication; `/user/«user
20+ 1 . it has the “OS2Form REST API user” (` os2forms_rest_api_user ` ) role,
21+ 2 . has been granted access to the formular
22+ (see [ Custom access control] ( #custom-access-control ) )
23+ 3 . has a generated key (User > Edit > Key authentication; `/user/«user
2224 id»/key-auth`).
2325
24- The “OS2Form REST API user” role gives read-only access to the API. To get read
26+ The “OS2Form REST API user” role gives read-only access to the API. To get write
2527access, a user must also have the “OS2Form REST API user (write)”
2628(` os2forms_rest_api_user_write ` ) role.
2729
2830## Endpoints
2931
30- | Name | Path | Methods |
31- | --------------------| ------------------------------------------------| ---------|
32- | Webform Elements | ` /webform_rest/{webform_id}/elements ` | GET |
33- | Webform Fields | ` /webform_rest/{webform_id}/fields ` | GET |
34- | Webform Submission | ` /webform_rest/{webform_id}/submission/{uuid} ` | GET |
35- | Webform Submit | ` /webform_rest/submit ` | POST |
36- | File | ` /entity/file/{file_id} ` | GET |
32+ | Name | Path | Methods |
33+ | ---------------------| ------------------------------------------------| ---------|
34+ | Webform Elements | ` /webform_rest/{webform_id}/elements ` | GET |
35+ | Webform Fields | ` /webform_rest/{webform_id}/fields ` | GET |
36+ | Webform Submission | ` /webform_rest/{webform_id}/submission/{uuid} ` | GET |
37+ | Webform Submissions | ` /webform_rest/{webform_id}/submissions ` | GET |
38+ | Webform Submit | ` /webform_rest/submit ` | POST |
39+ | File | ` /entity/file/{file_id} ` | GET |
3740
3841## Examples
3942
@@ -125,14 +128,45 @@ Response:
125128
126129(the ` sid ` value is a webform submission uuid).
127130
131+ ### Webform submissions
132+
133+ You can filter results based on submission time by
134+ adding query parameters to the url:
135+
136+ | Name | Value | Example |
137+ | -------------| ----------------------| --------------|
138+ | ` starttime ` | PHP DateTime formats | ` yesterday ` |
139+ | ` endtime ` | PHP DateTime formats | ` 2023-10-23 ` |
140+
141+ If left out, filtering upon the left out parameter will not be done.
142+
143+ The example beneath requests all submissions after October 1. 2023.
144+
145+ Request:
146+
147+ ``` sh
148+ > curl --silent --header ' api-key: …' ' https://127.0.0.1:8000/webform_rest/some_webform_id/submissions?starttime=2023-10-01'
149+ ```
150+
151+ Response:
152+
153+ ``` json
154+ {"webform_id" :" some_webform_id" ,
155+ "starttime" :" 2023-10-01" ,
156+ "submissions" :{
157+ "123" :" https:\/\/ 127.0.0.1:8000\/ da\/ webform_rest\/ some_webform_id\/ submission\/ 44b1fe1b-ee96-481e-b941-d1219d1dcb55" ,
158+ "124" :" https:\/\/ 127.0.0.1:8000\/ da\/ webform_rest\/ some_webform_id\/ submission\/ 3652836d-3dab-4919-b880-e82cbbf3c24c"
159+ }
160+ }
161+ ```
162+
128163## Custom access control
129164
130- To limit access to webforms, you can specify a list of API users that are
165+ To give access to webforms, you need to specify a list of API users that are
131166allowed to access a webform's data via the API.
132167
133168Go to Settings > General > Third party settings > OS2Forms > REST API to specify
134- which users can access a webform's data. ** If no users are specified, all API
135- users can access the data.**
169+ which users can access a webform's data.
136170
137171### Technical details
138172
0 commit comments