Appearance
远程健康检查
🏥 客户端连接状态检查
此接口用于检测用户客户端是否在线运行,支持远程监控客户端状态。
接口描述
根据 API KEY 检测对应用户的客户端是否正常运行。此接口用于监控客户端的连接状态,确保用户的工作流执行环境可用。
请求方式
GEThttps://newapi.iflyrpa.com/api/rpa-openapi/health/remote-check认证要求
需要带 BEARER KEY
请在请求头中添加:
Authorization: Bearer {YOUR_API_KEY}请求参数
此接口不需要额外的请求参数,认证信息通过请求头提供。
响应格式
成功响应 - 客户端在线 (HTTP 200)
json
{
"code": "0000",
"msg": "该用户客户端正常启动!",
"data": true
}失败响应 - 客户端离线 (HTTP 200)
json
{
"code": "5001",
"msg": "该用户客户端未启动!",
"data": false
}响应字段说明
| 字段名 | 类型 | 说明 |
|---|---|---|
| code | String | 响应代码,"0000" 表示成功(客户端在线),"5001" 表示失败(客户端离线) |
| msg | String | 响应消息,描述客户端状态 |
| data | Boolean | 客户端状态,true 表示在线,false 表示离线 |
状态说明
客户端在线
code: "0000"msg: "该用户客户端正常启动!"data: true- 表示用户的RPA客户端正在运行且连接正常
客户端离线
code: "5001"msg: "该用户客户端未启动!"data: false- 表示用户的RPA客户端未运行或连接异常
说明
- 此接口用于监控用户的客户端连接状态
- 客户端在线表示用户可以正常执行工作流
- 客户端离线表示用户无法执行工作流,需要启动客户端
- 建议在执行工作流前先调用此接口检查客户端状态
- 此接口响应速度快,适合频繁调用
代码示例
cURL
bash
curl -X GET "https://newapi.iflyrpa.com/api/rpa-openapi/health/remote-check" \
-H "Authorization: Bearer {YOUR_API_KEY}"Python
python
import requests
url = "https://newapi.iflyrpa.com/api/rpa-openapi/health/remote-check"
headers = {
"Authorization": "Bearer {YOUR_API_KEY}"
}
response = requests.get(url, headers=headers)
result = response.json()
print(f"响应码: {result['code']}")
print(f"消息: {result['msg']}")
print(f"客户端状态: {'在线' if result['data'] else '离线'}")
if result['data']:
print("✅ 客户端正常,可以执行工作流")
else:
print("❌ 客户端离线,请先启动客户端")JavaScript
javascript
const apiKey = "{YOUR_API_KEY}";
const url = "https://newapi.iflyrpa.com/api/rpa-openapi/health/remote-check";
fetch(url, {
method: "GET",
headers: {
"Authorization": `Bearer ${apiKey}`
}
})
.then(response => response.json())
.then(result => {
console.log(`响应码: ${result.code}`);
console.log(`消息: ${result.msg}`);
console.log(`客户端状态: ${result.data ? '在线' : '离线'}`);
if (result.data) {
console.log("✅ 客户端正常,可以执行工作流");
} else {
console.log("❌ 客户端离线,请先启动客户端");
}
})
.catch(error => console.error("Error:", error));工作流执行前的状态检查(Python)
python
import requests
def check_client_status():
"""检查客户端状态"""
url = "https://newapi.iflyrpa.com/api/rpa-openapi/health/remote-check"
headers = {
"Authorization": "Bearer {YOUR_API_KEY}"
}
try:
response = requests.get(url, headers=headers, timeout=10)
result = response.json()
return result['data'], result['msg']
except Exception as e:
return False, f"检查失败: {str(e)}"
def execute_workflow_safely(workflow_id, parameters=None):
"""安全执行工作流,先检查客户端状态"""
# 检查客户端状态
is_online, message = check_client_status()
if not is_online:
print(f"❌ 无法执行工作流: {message}")
return None
print(f"✅ 客户端状态正常: {message}")
# 执行工作流
execution_url = f"https://newapi.iflyrpa.com/api/rpa-openapi/workflows/{workflow_id}/execute/async"
headers = {
"Authorization": "Bearer {YOUR_API_KEY}",
"Content-Type": "application/json"
}
data = {"parameters": parameters or {}}
response = requests.post(execution_url, headers=headers, json=data)
return response.json()
# 使用示例
result = execute_workflow_safely("your-workflow-id", {"param1": "value1"})
if result:
print("工作流执行成功:", result)