# OpenAPI
# 一、基本介绍
OpenAPI 是一组基于HTTP/2的RESTFul接口,为跨平台集成BPM服务提供标准化访问能力。
# 核心特性
- 完整覆盖Yiez.Client功能集
- 支持多语言/多平台调用
- 采用标准的Bearer Token认证机制
# 二、快速入门
# 2.1 环境准备
- 安装包路径:
安装包/SourceCode/Demo/ - 解决方案文件:
Demo.sln
# 2.2 基础使用示例
# 发送信号示例
打开OpenAPI项目下的Signal.cs文件,找到17行:SendSignalAsync方法
这段代码演示如何通过OpenAPI发送信号:
// 创建支持HTTPS的HttpClient
var httpHandler = new HttpClientHandler();
httpHandler.ServerCertificateCustomValidationCallback =
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
// 初始化HTTP/2客户端
using (HttpClient httpClient = new HttpClient(httpHandler)
{
DefaultRequestVersion = new Version(2, 0);
}
{
// 1. 获取访问令牌
string token;
using (var response = await httpClient.PostAsJsonAsync(
"https://localhost:6001/v1/auth",
new {
clientKey = "system",
clientSecret = "6YmtHPNi0Ks6u8yzz6fGglhdoGzsSloz"
}))
{
var reply = await response.Content.ReadFromJsonAsync<AuthReply>();
token = reply.token;
}
// 2. 设置认证头
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", token);
// 3. 发送信号
using (var response = await httpClient.PostAsJsonAsync(
"https://localhost:6001/v1/workflow/execute/signal",
new {
signalName = "有人填了采购单",
uid = "99199",
data = new {
amount = 5,
orderItems = new[] {
new { name = "aaa", price = 1, qty = 1 },
new { name = "bbb", price = 2, qty = 2 }
}
}
}))
{
// 4. 处理响应
var reply = await response.Content.ReadFromJsonAsync<EmptyReply>();
if (reply.code != 0)
throw new Exception(reply.message);
Console.WriteLine($"信号发送成功");
}
}
# 三、接口文档
- 在线文档:
https://您的BPM服务器地址:6001/OpenAPI - 官方演示:
https://trial.flowportal.com:6001/OpenAPI
← Yiez.Client 单点登录 →