Reputation: 1179
I am using management API to schedule a task manage/v2/tasks?group-id=Default
and the JSON string that I send is
{
"task-enabled":true,
"task-path":"/MarkLogic/flexrep/tasks/push-local-forests.xqy",
"task-root": "Modules/",
"task-type": "minutely",
"task-period" : 1,
"task-database": "%%DATABASE%%",
"task-modules": "%%MODULES_DATABASE%%",
"task-user": "admin",
"task-priority": "higher"
}
My question is how to set the name of the task ? as by looking at manage-task-properties.xsd
it does not have a task name. So if I want to delete the task using management api, DELETE /manage/v2/tasks/{id|name}
it does require task name.
So I created a random task id task-id:9459386113689474276
into the above json and when I do this, the management api throws an exception
{
"errorResponse": {
"statusCode": "400",
"status": "Bad Request",
"messageCode": "MANAGE-INVALIDPAYLOAD",
"message": "MANAGE-INVALIDPAYLOAD: (err:FOER0000) Payload has errors in structure, content-type or values. Task payload invalid."
}
}
I look at the server logs, I find this
2017-09-12 20:11:37.721 Info: [Event:id=HTTPRequest ErrorFormat] Dispatching error code to app defined error handler: 500 manage/error-handler.xqy
2017-09-12 20:11:37.818 Info: Manage: MANAGE-INVALID (err:FOER0000): task-id
2017-09-12 20:11:37.818 Info: Manage: 169:16:/MarkLogic/manage/models/task-properties-model.xqy
How do I set the task-id
or task-name
so that I can use the management API to delete the task ? Since the Delete Management API does require the name|id
of the task to be deleted
******* EDIT *********
I want my FlexRep Scheduled task
to be explicitly deployed, and also only if a flexrep
is enabled for a particular environment. I understand I can remove the deploy task command, based on some user defined variable or env, but this will remove all the deployment of other tasks as well.
Is there a way where I can tell not to deploy a particular task ?
Upvotes: 2
Views: 129
Reputation: 2236
A scheduled task unfortunately does not have a name, but it does have a task path. When you create the scheduled task, MarkLogic will create the task ID for you - you're not allowed to set one yourself.
When you need to delete the task path, you'll need to look up the ID using the Management API - you'll most likely do that via the task path (it should be very rare to have two scheduled tasks with the same task path).
Note that ml-gradle - https://github.com/marklogic-community/ml-gradle - can handle all of this for you, in case using Gradle is an option for you and/or your team.
Upvotes: 2