Starting a Job Run Using the API

Once a job has been created and configured through the Cloudera Data Science Workbench web application, you can start a run of the job through the API. This will constitute sending a POST request to a job start URL of the form: http://cdsw.example.com/api/v2/projects/<$USERNAME>/<$PROJECT_NAME>/jobs/<$JOB_ID>/start.

To construct a request, use the following steps to derive the username, project name, and job ID from the job's URL in the web application.
  1. Log in to the Cloudera Data Science Workbench web application.
  2. Switch context to the team/personal account where the parent project lives.
  3. Select the project from the list.
  4. From the project's Overview, select the job you want to run.
    This will take you to the job Overview page. The URL for this page is of the form: http://cdsw.example.com/<$USERNAME>/<$PROJECT_NAME>/jobs/<$JOB_ID>.
  5. Use the $USERNAME, $PROJECT_NAME, and $JOB_ID parameters from the job Overview URL to create the following job start URL:
    http://cdsw.example.com/api/v2/projects/<$USERNAME>/<$PROJECT_NAME>/jobs/<$JOB_ID>/start
    For example, if your job Overview page has the URL http://cdsw.example.com/alice/sample-project/jobs/123, then a sample POST request would be of the form:
    curl -v -XPOST http://cdsw.example.com/api/v2/projects/alice/sample-project/jobs/123/start    \
    --user "<API_KEY>:" --header "Content-type: application/json"
    {
        "environment": {
            "ENV_VARIABLE": "value 1",
            "ANOTHER_ENV_VARIABLE": "value 2"
        }
    }