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

  1. Use the POST /twsd/api/v2/plan/job/submit-ad-hoc-job API endpoint.
  2. 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"
        }
      }
    }
  3. Click Execute.
    The API returns a success message, and the ad-hoc job is submitted.
  4. 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.