Start a Task¶
A task is started by a POST request to the action endpoint URL. The request body contains the action to be executed. For possible actions, refer to the Tasks description. Before starting the task, the different levels of metadata are merged into an input list for each document using the following order with ascending priority:
- Document metadata from repository
- Task metadata
- Task input list metadata
- Input list item
Example - endpoint URL for starting a task with ID taskId
for the operator-p4
service
/v1/services/operator-p4/tasks/<taskId>/action
with the request body
{
"action": "start"
}
The result will be the HTTP status code 204 and no response body. The action in the backend, PLOSSYS Output Engine for example, will be executed asynchronously.
Code Examples¶
Bash¶
Run the Create a Task and the Modify a Task Input List examples first and call the script with the returned taskId
.
#!/bin/bash
if [ -z $1 ]; then
echo "Please call with task id as parameter"
exit 0
fi
# !Assuming $TOKEN contains a valid JWT access token!
AUTH="Authorization: Bearer $TOKEN"
JSON="Content-Type:application/json"
# start the task and print http status code
ACTION=$(jq -c -n '{
"action":"start"
}')
curl -k -s -w '%{http_code}' -X POST -H "$AUTH" -H "$JSON" -d "$ACTION" "https://localhost:3008/v1/services/operator-p4/tasks/$1/action"
echo
JavaScript¶
Run the Create a Task and the Modify a Task Input List examples first and call the function with the returned taskId
.
'use strict';
const request = require('request-promise-native');
const startTask = async function(token, taskId) {
// start the task and print http status code
let req = {
url: `https://localhost:3008/v1/services/operator-p4/tasks/${taskId}/action`,
headers: {
Authorization: `Bearer ${token}`
},
body: {
action: 'start'
},
resolveWithFullResponse: true,
json: true,
strictSSL: false
}
let res = await request.post(req);
console.log(res.statusCode);
};