Skip to contents

[Experimental]

Usage

submission_create(
  pid = get_default_pid(),
  fid = get_default_fid(),
  xml = NULL,
  device_id = NULL,
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

xml

(character) The Submission XML as a single string.

device_id

(character) Optionally record a particular deviceID associated with this Submission. It is recorded along with the data, but Central does nothing more with it. Default: NULL (not sent).

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

Value

A list with the new Submission's metadata as per the ODK Central API docs, identical in shape to submission_detail(). Top level list elements are renamed from ODK's camelCase to snake_case.

Details

To create a Submission by REST rather than over the OpenRosa interface, POST the Submission XML to this endpoint. Unlike the OpenRosa Form Submission API, this interface does not accept Submission attachments upon Submission creation. Instead, the server determines which attachments are expected based on the Submission XML, and you can use attachment_upload() to add the attachments afterwards.

If the XML is unparseable or there is some other input problem with your data, Central answers 400. If a Submission already exists with the given instanceID, Central answers 409. The <meta> block holds a unique instanceID for each Submission.

Examples

if (FALSE) { # \dontrun{
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "me@email.com", pw = "...")

xml <- paste0(
  '<data id="simple" version="1">',
  "<meta><instanceID>uuid:85cb9aff-005e-4edd-9739-dc9c1a829c44</instanceID></meta>", # nolint
  "<name>Jo</name>",
  "</data>"
)

s <- submission_create(fid = "simple", xml = xml)

s$instance_id
# > "uuid:85cb9aff-005e-4edd-9739-dc9c1a829c44"
} # }