Updating a task with a new artifact version - Cloud

Updating artifact version in tasks via API

Version
Cloud
Language
English (United States)
Product
Talend Cloud
Module
Talend API Designer
Talend API Tester
Talend Data Preparation
Talend Data Stewardship
Talend Management Console
Content
Design and Development > Updating Tasks
Use the executables/tasks/<task_id> endpoint to update a task with a new artifact version.

Before you begin

Ensure that the account to be used to issue API calls has the Operations - Manage (ID: TMC_OPERATOR) permission.

About this task

In this section, Talend API Tester is used to demonstrate how to issue API calls to get the list of tasks.

Procedure

  1. On the Users page, generate a personal access token for your account if this is not done yet.
  2. Open Talend API Tester in your browser and select PUT from the Method list.
  3. In the field next to the Method drop-down list, enter the endpoint to be used: https://api.<your_environment>.cloud.talend.com/v2.6/executables/tasks/<task_id>
  4. In the HEADERS area, click Add header and in the name field that is displayed, enter Authorization and in the value field, enter Bearer and your personal access token. Enter a whitespace to separate Bearer and your personal access.
  5. In the BODY area, enter the name of the task to be updated, the workspace ID and the ID of the new artifact to be used.

    Example

    {
      "name": "task_name",
      "description": "",
      "workspaceId": "workspace_id",
    
      "artifact": {
        "id": "id_of_the_artifact_to_be_updated",    
        "version": "target_version_of_this_artifact (for example, 0.1.22.20212710014123)"
      }
    }
    This example contains only the required parameters to update a task.

    The artifactId parameter identifies the artifact to be updated and the workspaceId parameter indicates the workspace from which you get the tasks. You can obtain them through API requests or find them in Talend Cloud Management Console.

    • APIs:
      • use GET at the https://api.<your_environment>.cloud.talend.com/v2.6/artifacts endpoint for artifacts
      • use GET at the https://api.<your_environment>.cloud.talend.com/v2.6/workspaces for workspaces
    • In Talend Cloud Management Console, open the artifact list from the workspace and then open the artifact to be updated to see its ID. The ID of the workspace appears in the URL of the Edit workspace page.
  6. Click Send to issue your request to update the task.

Results

The status code 200 is returned with the task details in the body of the response. You can see the new artifact is being used. The following example shows how a task could look like in the response
{
  "id": "5c1111d7a4186a4eafed0587",
  "name": "Hello world task",
  "description": "task detail description",
  "workspace": {
    "id": "57f64991e4b0b689a64feed2",
    "name": "Personal",
    "description": "workspace detail description",
    "owner": "admin",
    "type": "custom",
    "environment": {
      "id": "57f64991e4b0b689a64feed3",
      "name": "Development",
      "description": "environment detail description",
      "default": true
    }
  },
  "version": "0.1",
  "artifact": {
    "createDate": "2021-11-22T13:13:27.608Z",
    "updateDate": "2021-11-22T13:13:27.608Z",
    "id": "id_of_the_artifact_to_be_updated",
    "name": "my_artifact",
    "version": "0.1.22.20212710014123" (The new  artifact version)
  },
  "tags": [
    "tag1",
    "tag2"
  ],
  "connections": {
    "aws": "5d405e381f40e07fbab6757c",
    "googledrive": "5d405e831f40e07fbab6757d"
  },
  "parameters": {
    "parameter_p1": "1111",
    "custom_parameter": "custom"
  },
  "resources": {
    "resource_file_f1": "5d567ad48f68ae1a1e16e4a4"
  },
  "autoUpgradeInfo": {
    "autoUpgradable": false,
    "overrideWithDefaultParameters": false
  }
}

In the real-world practice, you can develop your own script to automatically issue this request on each of the tasks you retrieved in the previous section: Getting tasks for which you need update the artifact version.

In the Downloads tab on the left, you can download an example of this kind of scripts, add appropriate values to the required parameters listed at the beginning of this script, and use it to automate the update of your tasks. This script is designed for demonstration purposes only. Talend does not provide support service for it.