Obtaining the Return Value of a Rest Client Node
The Rest Client node can execute RESTful requests.
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"
- Obtaining the Return Value Using an EL Expression
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.
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"))}
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot