JSON-RPC Client
调用 JSON-RPC 2.0 方法。
以 HTTP POST 发送一次 JSON-RPC 2.0 请求,返回 result 成员,或通过 error 端口返回 JSON-RPC error 成员。
工作原理
- 解析配置。
connection_id、method、params和id缺失时回退到输入 payload 中的同名键;connection_id和method为必填。 - 解析凭据:URL 为
config.url(或config.endpoint);若密钥含username和password,则使用 HTTP Basic 认证。 - 构建
{ jsonrpc: "2.0", method, params, id }:字符串形式的params会按 JSON 解析,缺失时为[];id默认为1。 - POST 该请求。响应含
error成员时从error输出;否则从out输出{ result }。
在工作流中
节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。
{
"node_id": "node-get-balance",
"label": "Get balance",
"operator_slug": "io.jsonrpc",
"operator_version": "1.0.0",
"config": {
"connection_id": "pi-credential-xxxx",
"method": "account.getBalance",
"params": "[\"{{ $json.account_id }}\"]",
"id": "1"
}
}{
"ok": true,
"data": {
"result": {
"balance": "1250.40",
"currency": "USD"
}
},
"port": "out"
}配置
-
connection_idstring 必填 -
JSON-RPC 端点的凭据。接受 `api-key` 或 `basic-auth` 类型的凭据。
-
methodstring 必填 -
方法名称
-
paramsstring 可选 -
参数(数组/对象,可为 JSON 字符串或数组)
-
idstring 可选 -
请求 ID
代码中的行为
除 schema 描述之外,实现代码对这些键的实际处理。
-
connection_id - 密钥中只读取
username+password(basic-auth);api-key凭据不会添加认证。以http://或https://开头的值会直接用作端点 URL,不带认证。 -
params - 接受数组、对象或 JSON 字符串;字符串会在发送前解析。
-
id - 按配置原样发送(在配置中设置时为字符串);为空时发送数字
1。
输出端口
out 默认 服务器返回 2xx 且无 error 成员。result 为 JSON-RPC 的 result。
{
"result": {
"balance": "1250.40",
"currency": "USD"
}
}error 响应包含 JSON-RPC error(数据为 { error: { code, message, data? } }),或请求失败(数据为 { error, response },其中 error 为消息字符串)。
{
"error": {
"code": -32601,
"message": "Method not found"
}
}在表达式中
后续节点可通过 $("JSON-RPC Client").item.json.<路径> 读取此节点输出中的内容(请把 JSON-RPC Client 换成你的节点标签)。Editor 标记工作流编辑器在 Previous Nodes 中提示的路径(输出契约);Worker 标记 worker 实际通过 out 返回的路径,依据“端口”一节所示的输出。
| 表达式 | Editor | Worker |
|---|---|---|
$("JSON-RPC Client").item.json.resultJSON-RPC 结果 | ||
$("JSON-RPC Client").item.json.result.balance | — | |
$("JSON-RPC Client").item.json.result.currency | — |
— Worker: worker 会返回它,但编辑器不会提示:请手动输入。对象内部的键可能取决于你的数据或配置(例如每个标签一个键)。
错误
| 消息 | 端口 | 原因与处理 |
|---|---|---|
connection_id is required | error | 未选择凭据。 |
method is required | error | 配置和输入 payload 中的方法名均为空。 |
<JSON parse error> | error | params 是无效 JSON 字符串。请写成 JSON 数组或对象,例如 ["acc_001"]。 |
Request failed with status code <status> | error | HTTP 调用返回非 2xx 状态;response 中包含正文。 |
输入契约
-
connection_idstring 必填 -
methodstring 必填 -
paramsstring 可选 -
idstring 可选
输出契约
-
resultobject 可选 -
JSON-RPC 结果
契约(JSON Schema)
与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。
{
"slug": "io.jsonrpc",
"name": "JSON-RPC Client",
"category": "io",
"version": "1.0.0",
"description": "Call JSON-RPC 2.0 Method.",
"capabilities": [
"jsonrpc",
"api",
"http"
],
"config_schema": {
"type": "object",
"properties": {
"connection_id": {
"type": "string",
"title": "JSON-RPC Credential",
"description": "Credential for the JSON-RPC endpoint. Accepts credentials of type `api-key` or `basic-auth`.",
"ui_widget": "connection_picker",
"ui_options": {
"credential_types": [
"api-key",
"basic-auth"
],
"types": [
"jsonrpc",
"http"
]
}
},
"method": {
"type": "string",
"description": "Method Name"
},
"params": {
"type": "string",
"description": "Parameters (Array/Object as JSON string or array)"
},
"id": {
"type": "string",
"default": "1",
"description": "Request ID"
}
},
"required": [
"connection_id",
"method"
]
},
"input_contract_schema": {
"type": "object",
"properties": {
"connection_id": {
"type": "string"
},
"method": {
"type": "string"
},
"params": {
"type": "string"
},
"id": {
"type": "string"
}
},
"required": [
"connection_id",
"method"
]
},
"output_contract_schema": {
"type": "object",
"properties": {
"result": {
"type": "object",
"description": "JSON-RPC Result"
}
}
},
"ports": [
{
"port_id": "out",
"label": "Result",
"description": "JSON-RPC Result",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "JSON-RPC Error",
"is_default": false,
"supports_condition": false
}
],
"execution_mode": "async",
"required_resources": [],
"compatible_worker_pools": [
"standard-io"
],
"tags": [
"rpc",
"api"
],
"is_stateful": false,
"publisher": {
"identity": "org_link_loom",
"profile": {
"name": "Link Loom",
"verified": true,
"url": "https://me.veripass.com/link-loom",
"logo_url": null
}
}
}{
"type": "object",
"properties": {
"connection_id": {
"type": "string",
"title": "JSON-RPC Credential",
"description": "Credential for the JSON-RPC endpoint. Accepts credentials of type `api-key` or `basic-auth`.",
"ui_widget": "connection_picker",
"ui_options": {
"credential_types": [
"api-key",
"basic-auth"
],
"types": [
"jsonrpc",
"http"
]
}
},
"method": {
"type": "string",
"description": "Method Name"
},
"params": {
"type": "string",
"description": "Parameters (Array/Object as JSON string or array)"
},
"id": {
"type": "string",
"default": "1",
"description": "Request ID"
}
},
"required": [
"connection_id",
"method"
]
}{
"type": "object",
"properties": {
"connection_id": {
"type": "string"
},
"method": {
"type": "string"
},
"params": {
"type": "string"
},
"id": {
"type": "string"
}
},
"required": [
"connection_id",
"method"
]
}{
"type": "object",
"properties": {
"result": {
"type": "object",
"description": "JSON-RPC Result"
}
}
}[
{
"port_id": "out",
"label": "Result",
"description": "JSON-RPC Result",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "JSON-RPC Error",
"is_default": false,
"supports_condition": false
}
]执行
- 执行方式
async- 有状态
- 否
- 凭据
- 在服务器端根据
connection_id解析,密钥不会进入工作流。 - 能力
jsonrpcapihttp- 标签
rpcapi
说明与限制
- 每次运行一个请求;不支持批量请求和通知(无
id的请求)。无超时,也不重试。
已对照编排器代码核实 · 31e874b · 2026-11-26