Click or drag to resize
POST /forms
Print this page
Description

This service is used to submit one or more forms. These forms contain the response data that a driver provided for each form item. A form can be updated until it has been set to read only. Forms that do not support multiple versions become read only when first saved with the Submitted status.

The ability to store multiple versions is controlled by the form template.

Example of a request that creates a new Submitted form:

POST /forms
[  
   {  
      "id":"26fc499ae0784cab94ce4adddf4d7a93",
      "template":"72fed18ca98445bdb31b5c545ccb7bb0",
      "versionId":"8618d37b265b40d8b8809c5e1046d399",
      "values":"<instance name=\"abc\" loc=\"-43.5441624,172.5914094\"><textbox name=\"Text\" id=\"2\" required=\"false\">foo<\/textbox><\/instance>"
   }
]

Example of a request that creates a Saved (draft) form:

POST /forms
[  
   {  
      "id":"cd63e0e3be174550919ad6752ad15f42",
      "template":"72fed18ca98445bdb31b5c545ccb7bb0",
      "versionId":"935d3435153c4306a37781811618204a",
      "status":"Saved",
      "submissionTime":"2016-08-23T01:01:01Z",
      "values":"<instance name=\"abc\" loc=\"-43.5441624,172.5914094\"><textbox name=\"Text\" id=\"2\" required=\"false\">initial value<\/textbox><\/instance>"
   }
]

Example of a request that updates a form by posting a revision with the same id. The previousVersionId must refer to the versionId of the most recent revision:

POST /forms
[  
   {  
      "id":"cd63e0e3be174550919ad6752ad15f42",
      "template":"72fed18ca98445bdb31b5c545ccb7bb0",
      "versionId":"275703de682a4e218765e188288bc2f1",
      "previousVersionId":"935d3435153c4306a37781811618204a",
      "status":"Submitted",
      "submissionTime":"2016-08-23T01:23:17Z",
      "values":"<instance name=\"abc\" loc=\"-43.5441624,172.5914094\"><textbox name=\"Text\" id=\"2\" required=\"false\">new value<\/textbox><\/instance>"
   }
]
Note Note

To save a new version of a form, the form's id and the XML's versionId property must be specified in the JSON request body. The versionId should be kept from the previous version's XML.

Remarks
  • If an id is supplied, then the service interprets the request as a create or update request. If no form instance exists with the specified id, then a new form instance is created. Otherwise, the existing form instance is updated.
  • If you post a form and do not specify an id, then the service creates a new form instance and assigns it a new unique id. However, this is legacy behavior, and we do not recommend it. The best practice is to supply an id with all create and update requests.
  • Multiple versions of the same form can be submitted in a single request if the request includes the previousVersionId for each revision. Forms are processed in the order that they are submitted and must be sorted accordingly.
  • If a form is marked as "read only" it cannot be updated.
  • When reading from the server, all of the following GUID properties are formatted as alphanumeric strings, without dashes: id, versionId, previousVersionId, and template. When posting to the server, these GUID properties are allowed to contain dashes.
  • When posting a form, the submissionTime must be unique. If this property has the same value as a previous revision, then the request is ignored.
Request

The Request body is a JSON array of form objects describing the forms to be submitted:

Member Type Purpose
id string (required) A GUID that uniquely identifies the form.
versionId string (required) A GUID that uniquely identifies the revision of the form.
previousVersionId string (required if a previous revision exists) A GUID that uniquely identifies this revision's parent revision.
template string (required) A GUID that uniquely identifies the template on which this form is based.
status string Indicates the current status of the form. Values: Submitted (default), Saved. This field can be updated through the API. If not specified, this field defaults to Submitted. If Saved, the form can be retrieved for completion and submission.
submissionTime string The ISO 8601 timestamp for when this form was changed to Submitted. Read-only once set. If not provided, it is set by the server automatically.
values string (required) A string containing an XML document that contains all the values submitted by the user into this form. The structure of this XML document should match the form template: This field can be updated through the API.
job string Uniquely identifies the job that is associated with this form. This field is required when creating a new form.
lastUpdateTime string (read-only) The most recent timestamp for the form, which is the submitted time, update time, or creation time (in that order).
driverName string (read-only) The tag for the driver who is associated with the form.
unitName string (read-only) The tag for the driver's unit at the time that the form was last updated.
jobName string (read-only) The tag for the job that is associated with the form.
address string (read-only) The form's address, which is the driver's location (usually the job site) when last updating the form.
formType string (read-only) The form's type, which is given by the template that this form is based on. This is "standard" by default.
readOnly bool? (read-only) Indicates whether form cannot be edited.
versionNumber int? (read-only) The current version number of the form instance. The version number starts at 1 and increments on the next revision after each submitted revision. Saved revisions share the same version number as their submitted revision.
previousVersions Form[] (read-only) The list of previously submitted form objects (the content of this property is controlled by the "history" request parameter).
fields FormField[] (read-only) The content of the form as a flat list of the Field objects detailed below (this property is omitted by default, to include use the "return_fields=true" request parameter).
Member Type Purpose
id string (read-only) Uniquely identifies the field. This is an integer identifier.
name string (read-only) Name of the field.
type string (read-only) Type of the field.
value string (read-only) Value of the field.
templateRevisionNumber int? (read-only) The revision number of the template used to create this form.
openTime string (read-only) Time when the form was most recently opened by the user for editing.
closeTime string (read-only) Time when the form was most recently closed by the user after editing was complete.
openDuration int (read-only) The length of time that this form revision was edited for, in seconds

Response

On success, the response body contains a JSON array of form objects. There will be one entry in the array for each entry in the request body. Only the id, versionId, versionNumber, and readOnly properties of the Forms are returned.

If the request fails, an Error Response is generated.