odk@3.0.3
- get(path, options)
- getForms(projectId)
- getSubmissions(projectId, xmlFormId, query)
- post(path, body, options)
- request(method, path, body, options)
This adaptor exports the following from common:
- cursor()
- dataPath()
- dataValue()
- dateFns
- each()
- field()
- fields()
- fn()
- fnIf()
- lastReferenceValue()
- merge()
- sourceValue()
Functions
get
get(path, options) ⇒ Operation
Make a GET request against the ODK server.
Param | Type | Description |
---|---|---|
path | string | Path to resource |
options | RequestOptions | Options to configure the HTTP request |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | the parsed response body |
response | the response from the ODK HTTP server (with the body removed) |
references | an array of all the previous data values |
Example: Get a list of available projects
get("v1/projects");
Example: Get projects with query parameters
get("v1/projects", {
query: { datasets: true }
});
getForms
getForms(projectId) ⇒ Operation
Fetch all forms for a project.
Param | Type | Description |
---|---|---|
projectId | number | Id of the project |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | array of form data objects |
response | the response from the ODK HTTP server (with the body removed) |
references | an array of all the previous data values |
Example: Fetch all forms for project with id 22
getForms(22);
getSubmissions
getSubmissions(projectId, xmlFormId, query) ⇒ Operation
Fetch all submissions to a given form.
Param | Type | Description |
---|---|---|
projectId | number | Id of the project the form belongs to |
xmlFormId | string | Id of the form to fetch submissions for |
query | string | Query parameters to append to the request, see https://docs.getodk.org/central-api-odata-endpoints/#data-document |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | array of form submission objects |
response | the response from the ODK HTTP server (with the body removed) |
references | an array of all the previous data values |
Example: Get all submissions to a form called 'patient-follow-up'
getSubmissions(22, 'patient-follow-up');
Example: Filter submissions since a given date
getSubmissions(22, 'patient-follow-up', { $filter: "$root/Submissions/__system/submissionDate gt 2020-01-31T23:59:59.999Z" });
post
post(path, body, options) ⇒ Operation
Make a POST request against the ODK server.
Param | Type | Description |
---|---|---|
path | string | Path to resource |
body | object | Object which will be attached to the POST body |
options | RequestOptions | Options to configure the HTTP request |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | the parsed response body |
response | the response from the ODK HTTP server (with the body removed) |
references | an array of all the previous data values |
Example: Create a new project
post('v1/projects', { name: 'Project Name' });
request
request(method, path, body, options) ⇒ Operation
Make a general HTTP request against the ODK server.
Param | Type | Description |
---|---|---|
method | string | HTTP method to use |
path | string | Path to resource |
body | object | Object which will be attached to the body |
options | RequestOptions | Optional request params |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | the parsed response body |
response | the response from the ODK HTTP server (with the body removed) |
references | an array of all the previous data values |
Example: Make a POST request to create a new project
request("POST", 'v1/projects', { name: 'Project Name' });
Interfaces
RequestOptions
Options provided to the HTTP request
Properties
Name | Type | Description |
---|---|---|
query | object | An object of query parameters to be encoded into the URL. |
headers | object | An object of headers to append to the request. |
parseAs | string | Parse the response body as json, text or stream. By default will use the response headers. |
timeout | number | Request timeout in ms. Default: 300 seconds. |