Skip to main content Skip to complementary content

Configuring the components for calling the MetaServlet REST Web service to execute a task

Procedure

  1. Double-click the tSetGlobalVar component to display its Basic settings view in the Component tab.
  2. Click the [+] button to add a line in the Variables table:
    • In the Key field, type in jsonEncoded

    • In the Value fields, type in:

      MetaServlet.base64Encode("{\"actionName\":\"runTask\",\"taskId\":\"" + context.task_id + "\",\"mode\"
      :\"synchronous\",\"context\":{\"Default\":\"" + ((String)globalMap.get("tMsgBox_1_RESULT")) + "\"},
      \"authPass\":\"" + context.tac_pwd + "\",\"authUser\":\"" + context.tac_user + "\"}") 

      to call the routine you have previously created.

  3. Then double-click the tREST component to display its Basic settings view.
  4. Fill the URL field with the URL of the Web service you are going to invoke. For this use case, type in:
    context.tac_url + "/metaServlet?" +((String)globalMap.get("jsonEncoded"))

    to call the service and encode the MetaServlet parameters in a Json format.

  5. From the HTTP Method list, select GET to send an HTTP request for generating a task.
    In this way, the MetaSerlet is invoked via the REST API of Talend Administration Center with the relevant parameters.
  6. In the Basic settings view of the tLogRow component, select the Basic option to display the result in the Run console.
  7. Save your Job and press F6 to launch it.

Results

The console shows that the tREST component sends an HTTP request to the server end to run the specified task, and that the task has been executed without errors.

In the Job Conductor page of Talend Administration Center, the status of the task is now ready to run.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!