3.2.10 JSON RPC Task
Use the JSON RPC task to invoke JSON-RPC 2.0 services over HTTP(S) using
POST requests with application/json payloads. It supports single-call mode
for one RPC invocation and batched requests (array) for multiple calls in a single HTTP
request.
When to use this task
Use this task to:
- Call JSON-RPC services. For example, blockchain nodes, such as Ethereum methods or custom RPC APIs as part of your workflow.
- Batch multiple JSON-RPC calls in a single HTTP request for efficiency.
- Fire-and-forget notification calls by omitting the
idfield (server does not reply for those items).
This task constructs standardized JSON-RPC 2.0 payloads from UI inputs, sends them to the endpoint, and captures responses for workflow processing.
Do not use this task for calls to HTTP server and use it only to call JSON-RPC compliant APIs.
To add a JSON RPC Task
-
Navigate to the Task tab in a workflow and view all the tasks that you can add using the Workflow Builder. See Access the Task Tab in Workflow Builder.
- In the More Tasks dialog box, click JSON RPC Task to add it to the workflow.
-
Click the task that you have added in the left pane. The Task tab in the right pane displays details about the task, such as its name and parameters. Next, let's provide details for the task.
-
In the Task Details group, enter the following information.
- Task Name: Mandatory. Enter a unique name for the task. The name must be between 1 to 128 alphanumeric characters in length and cannot contain spaces or any special characters. Optionally, you can use underscore (_) and hyphen (-).
- Task Reference: Mandatory. Enter a value to refer to the task within a workflow definition. This value must be unique within a workflow. The task reference value must be between 1 to 128 alphanumeric characters in length and cannot contain spaces or any special characters. Optionally, you can use underscore (_) and hyphen (-).
- In the JSON_RPC Task Parameters group,
provide the following information.
- Endpoint URI: Mandatory. Target HTTPS or HTTP URL for the JSON-RPC POST request.
- Batch Request: Select this option to enable batch mode for multiple RPC calls in one payload. By default, this option is not selected.
- Accept: Select the accepted media types in the accept header of the request.
- Content-Type: Select the supported
media type. If you select
application/jsonas the media type, all the content in the request body must be encoded in JavaScript Object Notation (JSON). - RPC Method: Mandatory only for
single-call mode. Enter the JSON-RPC method name. The name is case
sensitive. Maps to
methodin payload and it is ignored in the batch mode. - Request ID: Optional. It correlates the request and response. This option is used only in only for single-call mode and is ignored in the batch mode. Omit for JSON‑RPC notifications where server MUST NOT reply for a request.
- Params (JSON object or array):
Specify the JSON-RPC parameters. In the single call mode, enter an array
or a map of named objects. In the batch mode, enter an array of
BatchItemobjects which provides details for the following.rpcMethod: Required.params: Optional. Enter a map of named objects.id: Optional. It correlates the request and response. Omit for JSON‑RPC notifications where server MUST NOT reply for a request.
- Connection Timeout (ms): Maximum permissible time, in milliseconds (ms), to establish a TCP connection. Default value is 5000 ms.
- Read Timeout (ms): Maximum permissible time, in milliseconds (ms), to read full response after connection. The default value is 60000 ms. You can tune this for large payloads, such as transaction logs.
- Add Header: Add custom HTTP headers, as key-value pairs, that you want to pass in the header section of a request or response.
-
Click Save to save the changes to the workflow.
MicroTx Workflows displays the changes in JSON code.
-
Review all the changes, and then click Confirm Save to save the changes.
If you do not want to save the changes, click Cancel, and then click Reset to undo all the changes that you have made since the workflow was last saved.
Parent topic: Create System Tasks and Operator Tasks