Help Center> DataArts Studio> Best Practices> Advanced Data Development Guidance> Obtaining the Return Value of a Rest Client Node
Updated on 2023-09-27 GMT+08:00

Obtaining the Return Value of a Rest Client Node

The Rest Client node can execute RESTful requests on Huawei Cloud.

This tutorial describes how to obtain the return value of the Rest Client node, covering the following two application scenarios:

Obtaining the Return Value Through Parameter "The response message body parses the transfer parameter"

As shown in Figure 1, the first Rest Client node invokes the API of MRS to query the cluster list. Figure 2 shows the JSON message body returned by the API.

  • Scenario: The ID of the first cluster in the cluster list needs to be obtained and transferred to other nodes as a parameter.
  • Key configurations: Set The response message body parses the transfer parameter of the first Rest Client to clusterId=clusters[0].clusterId. Other Rest Client nodes can reference the ID of the first cluster in ${clusterId} mode.

    When setting The response message body parses the transfer parameter, ensure that the transferred parameter name (for example, clusterId) is unique among all node parameters of the job.

Figure 1 Rest Client job example 1

Figure 2 JSON message body

Obtaining the Return Value Using an EL Expression

The Rest Client node can be used together with EL expressions. You can select different EL expressions based on scenarios. This section describes how to develop your own jobs based on your service requirements. For details about how to use EL expressions, see EL Expressions.

As shown in Figure 3, the Rest Client invokes the API of MRS to query the cluster list and then invokes the Kafka Client to send a message.

  • Scenario: The Kafka Client sends a character string message. The message content is the ID of the first cluster in the cluster list.
  • Key configurations: When you configure the Kafka Client, use the following EL expression to obtain a specific field in the message body returned by the REST API: #{JSONUtil.toString(JSONUtil.path(Job.getNodeOutput("Rest_Client_4901"),"clusters[0].clusterId"))}
Figure 3 Rest Client job example 2