Imports a batch of records into a form.
This job requires a specially formatted file as input. The file must have the following format:
- The first line identifies the format and must be exactly equal to:
LINE DELIMITED JSON RECORDS
- The second line must contain the number of records to import
- The third line is a JSON-encoded array of fields that will be imported.
Following the third header line, each subsequent line must contain a JSON array with the following:
- The id of the record to update, or
null
if the server should generate a new id - The id of the parent record. If this is not subform, this should be omitted
- The value, encoded as JSON, of each the fields listed in the header.
For example:
LINE DELIMITED JSON RECORDS
3
["field1", "field2", "field3"]
[null, "Bob", 42, "1980-01-01"]
[null, "Alice", 38, "1982-01-01"]
Starting the job
This operation is a long-running batch job. You must first submit a request to start the job.
POST https://www.activityinfo.org/resources/jobs
Request body
object | |||
type | string | The type of the job to start. Must be "importRecords" |
required |
descriptor | object | required | |
formId | string | The id of the form into which the records should be imported. | required |
importId | string | The id of the previously-staged import. | required |
Getting the job status
The result of this first call provides a job id that you can use to poll for status:
GET https://www.activityinfo.org/resources/jobs/{jobId}
curl -X GET https://www.activityinfo.org/resources/jobs/ahBlfmFjdGl2aXR5aW5mb2V1chALEgNKb2IYgICAzd390wkM \
-u anything:APITOKEN \
-H 'Content-type: application/json' \
--data-binary @- << EOF
{
"id": "ahBlfmFjdGl2aXR5aW5mb2V1chALEgNKb2IYgICAzd390wkM",
"state": "STARTED"
}
EOF
Successful result
When the job state transitions to "COMPLETED"
, the status object will include the result:
object | |||
id | string | The id of the job | required |
state | string | "COMPLETED" |
required |
result | object | required |