REST API - submitting an ad-hoc job
Use REST APIs to submit an ad-hoc job.
About this task
This process involves submitting an ad-hoc job through a POST REST API.
Procedure
- Use the POST /twsd/api/v2/plan/job/submit-ad-hoc-job API endpoint.
-
In the request body, define the task and the workstationKey.
The following examples show different task definitions:
Simple Task
{ "task": { "UNIX": { "taskString": "ls", "isCommand": "true", "userName": "wauser" } } }Executable Task (Corrected)
{ "task": { "OTHER": { "taskString": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<jsdl:jobDefinition xmlns:jsdl=\"http://www.ibm.com/xmlns/prod/scheduling/1.0/jsdl\" xmlns:jsdle=\"http://www.ibm.com/xmlns/prod/scheduling/1.0/jsdle\" name=\"executable\">\n <jsdl:application name=\"executable\">\n <jsdle:executable interactive=\"false\">\n <jsdle:script>ls</jsdle:script>\n </jsdle:executable>\n </jsdl:application>\n<jsdl:jobDefinition>", "userName": "wauser" } } }The following example shows a complete JSON request body:
{ "workstationKey": "WA_AGT", "task": { "UNIX": { "taskString": "ls", "isCommand": "true", "userName": "wauser" } } } -
Click Execute.
The API returns a success message, and the ad-hoc job is submitted.
- To verify the submission, run the GET /twsd/api/v2/plan/job API call. Check that the ad-hoc job is successfully added to the plan.