Skip to main content

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.

ParamTypeDescription
pathstringPath to resource
optionsRequestOptionsOptions to configure the HTTP request

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the ODK HTTP server (with the body removed)
referencesan 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.

ParamTypeDescription
projectIdnumberId of the project

This operation writes the following keys to state:

State KeyDescription
dataarray of form data objects
responsethe response from the ODK HTTP server (with the body removed)
referencesan 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.

ParamTypeDescription
projectIdnumberId of the project the form belongs to
xmlFormIdstringId of the form to fetch submissions for
querystringQuery 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 KeyDescription
dataarray of form submission objects
responsethe response from the ODK HTTP server (with the body removed)
referencesan 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.

ParamTypeDescription
pathstringPath to resource
bodyobjectObject which will be attached to the POST body
optionsRequestOptionsOptions to configure the HTTP request

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the ODK HTTP server (with the body removed)
referencesan 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.

ParamTypeDescription
methodstringHTTP method to use
pathstringPath to resource
bodyobjectObject which will be attached to the body
optionsRequestOptionsOptional request params

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the ODK HTTP server (with the body removed)
referencesan 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

NameTypeDescription
queryobjectAn object of query parameters to be encoded into the URL.
headersobjectAn object of headers to append to the request.
parseAsstringParse the response body as json, text or stream. By default will use the response headers.
timeoutnumberRequest timeout in ms. Default: 300 seconds.