MarkLogic 9 Product Documentation
POST /manage/v2/tasks

Summary

This resource address is used to create a new scheduled task for the specified group. For an example, see Creating a Push Replication Scheduled Task in the Scripting Administrative Tasks Guide.

URL Parameters
group-id The id or name of the group to which the tasks belong. The group must be specified by this parameter or by the group-name property in the request payload. If it is specified in both places, the values must be the same.
server-type The type of App Server to create. The App Server type must be specified by this parameter or in the request payload. If it is specified in both places, the values must be the same. The valid types are: http, odbc, xdbc, or webdav.
format The format of the posted data. Can be either html, json, or xml (default). This value overrides the Accept header if both are present.
Request Headers
Accept The expected MIME type of the request body. If the format? parameter is present, it takes precedence over the Accept header.
Content-type The MIME type of the data in the request body. Depending upon the value of the format parameter or Accept header, one of application/xml, application/json, or text/html.
Response Headers
Content-type The MIME type of the data in the response body. Depending upon the value of the format parameter or Accept header, one of application/xml, application/json, or text/html.
Location If the request causes a restart, a Location header is included in the reponse. The header contains a path with which to construct a URL to usable to test when the restart has completed.

Response

Upon success, MarkLogic Server returns status code 201 (Created). If the task exists or if the payload is malformed, a status code of 400 (Bad Request) is returned. A status code of 401 (Unauthorized) is returned if the user does not have the necessary privileges.

Required Privileges

This operation requires the manage-admin role, or the following privilege:

http://marklogic.com/xdmp/privileges/manage-admin

The security role is required to set the task-user property.

Usage Notes

If your task is in the filesystem, rather than a database, do not include the task-database property. The task-start-time property must be in xs:time format ("24:00"). The task-type property is (minutely|hourly |daily|weekly|monthly|once). If not supplied, the default value is once. The task-days property is an array containing (sunday, monday, tuesday, wednesday, thursday, friday, saturday). The task-priority property is (normal|higher), if not supplied, default value is normal.

Note: The properties described here are for XML payloads. In general they are the same for JSON, with the exception that, in JSON, task-days is expressed in singular form. For example, in JSON, task-days is instead task-day and the format is as shown in the following example.

task-id

The task ID.

task-enabled

Whether or not a task is enabled

task-path

The module to invoke.

task-root

The path to the module directory root.

task-type

What type of scheduled task is this.

task-period

How often this task should run (every n months, weeks, days, hours or minutes).

task-month-day

The day of the month that this task runs on.

task-days

The days that this task runs on.

This is a complex structure with the following children:

task-day

A day that this task runs on.

task-start-date

The starting date (in MM/DD/YYYY notation) for this task.

task-start-time

The starting time (in 24:00 notation) for this task.

task-timestamp

The date and time this task was created.

task-database

The database name.

task-modules

The database that contains application modules.

task-user

The user to run this task as.

task-host

The host to run this task on.

task-priority

The priority of this task.

Example


cat myTask.json
==> 
{
   "task-enabled":true, 
   "task-path":"/path/to/query.xqy", 
   "task-root":"/", 
   "task-type":"weekly", 
   "task-period":2, 
   "task-day":["tuesday"], 
   "task-start-time":"12:00:00-08:00", 
   "task-timestamp":"2014-11-24T14:23:51.468616-08:00", 
   "task-database":"Documents", 
   "task-modules":"", 
   "task-user":"nobody"
}

curl -X POST --digest -u admin:admin -H "Content-type: application/json" \
-d @myTask http://localhost:8002/manage/v2/tasks?group-id=Default

==>  Creates a task in the Default group to run "/path/to/query.xqy" on Tuesday
     every other week at 12:00. 
    
Powered by MarkLogic Server | Terms of Use | Privacy Policy