第 28 章 知识存储 Business Central 空间和项目的 REST API


Red Hat Process Automation Manager 提供了一个 知识库存储 REST API,您可以使用它们与红帽流程自动化管理器中的项目和空格交互,而无需使用 Business Central 用户界面。知识库存储是 Red Hat Process Automation Manager 中资产的工件存储库。通过此 API 支持,您可以促进和自动化 Business Central 项目和空格维护。

使用 知识库 REST API,您可以执行以下操作:

  • 检索有关所有项目和空格的信息
  • 创建、更新或删除项目和空格
  • 构建、部署和测试项目
  • 检索有关之前关于存储 REST API 请求或作业的信息

知识存储 REST API 请求需要以下组件:

身份验证

知识库存储 REST API 需要对用户角色 rest-all 进行 HTTP 基本身份验证或基于令牌的身份验证。要查看为您的 Red Hat Process Automation Manager 分发配置的用户角色,请导航到 ~/$SERVER_HOME/standalone/configuration/application-roles.properties~/application-users.properties

要添加具有 rest-all 角色的用户,请导航到 ~/$SERVER_HOME/bin,再运行以下命令:

$ ./bin/jboss-cli.sh --commands="embed-server --std-out=echo,/subsystem=elytron/filesystem-realm=ApplicationRealm:add-identity(identity=<USERNAME>),/subsystem=elytron/filesystem-realm=ApplicationRealm:set-password(identity=<USERNAME>, clear={password='<PASSWORD>'}),/subsystem=elytron/filesystem-realm=ApplicationRealm:add-identity-attribute(identity=<USERNAME>, name=role, value=['rest-all'])"

有关用户角色和 Red Hat Process Automation Manager 安装选项的更多信息,请参阅 规划 Red Hat Process Automation Manager 安装

HTTP 标头

知识库存储 REST API 需要为 API 请求使用以下 HTTP 标头:

  • 接受: 请求客户端接受的数据格式:

    • application/json (JSON)
  • Content-Type: POSTPUT API 请求数据的数据格式:

    • application/json (JSON)
HTTP 方法

知识库存储 REST API 支持以下 API 请求 HTTP 方法:

  • GET :从指定的资源端点检索指定的信息
  • POST :创建或更新资源
  • PUT :更新资源
  • DELETE :删除资源
基本 URL

知识库 REST API 请求的基本 URL 是 http://SERVER:PORT/business-central/rest/,如 http://localhost:8080/business-central/rest/。

注意

知识库存储的 REST API 基础 URL 以及内置在 Business Central 中的流程自动化管理器控制器是相同的,因为两者都被视为 Business Central REST 服务的一部分。

Endpoints

了解存储 REST API 端点,如指定空间的 /spaces/{spaceName},是您附加到 知识库 REST API 基础 URL 中的 URI,以访问 Red Hat Process Automation Manager 中的相应资源或资源类型。

/spaces/{spaceName} 端点的请求 URL 示例

http://localhost:8080/business-central/rest/spaces/MySpace

请求数据

知识库 REST API 中的 HTTP POST 请求可能需要 JSON 请求正文,并附带请求。

POST 请求 URL 和 JSON 请求正文数据示例

http://localhost:8080/business-central/rest/spaces/MySpace/projects

{
  "name": "Employee_Rostering",
  "groupId": "employeerostering",
  "version": "1.0.0-SNAPSHOT",
  "description": "Employee rostering problem optimisation using Planner. Assigns employees to shifts based on their skill."
}

知识库存储 REST API 可让您与 Red Hat Process Automation Manager 中的项目和空格交互,而无需使用 Business Central 用户界面。您可以使用任何 REST 客户端或 curl 工具发送知识库 REST API 请求。

先决条件

  • Business Central 已安装并运行。
  • 您有 rest-all 用户角色对 Business Central 的访问权限。

流程

  1. 识别您要向其发送 请求的相关 API 端点,如 [GET] /spaces 以检索 Business Central 中的空格。
  2. 在 REST 客户端或 curl 工具中,为对 /spaceGET 请求输入以下组件。根据您的用例调整任何请求详情。

    对于 REST 客户端:

    • 身份验证 :使用 rest-all 角色输入 Business Central 用户的用户名和密码。
    • HTTP Headers :设置以下标头:

      • 接受:application/json
    • HTTP 方法 :设置为 GET
    • URL :输入知识库 REST API 基本 URL 和端点,如 http://localhost:8080/business-central/rest/spaces

    对于 curl 工具:

    • - U :输入 Business Central 用户的用户名和密码,以及 rest-all 角色。
    • - h : 设置以下标头:

      • 接受:application/json
    • -x :设置为 GET
    • URL :输入知识库 REST API 基本 URL 和端点,如 http://localhost:8080/business-central/rest/spaces
    curl -u 'baAdmin:password@1' -H "Accept: application/json" -X GET "http://localhost:8080/business-central/rest/spaces"
  3. 执行请求并查看 KIE 服务器响应。

    服务器响应示例(JSON):

    [
      {
        "name": "MySpace",
        "description": null,
        "projects": [
          {
            "name": "Employee_Rostering",
            "spaceName": "MySpace",
            "groupId": "employeerostering",
            "version": "1.0.0-SNAPSHOT",
            "description": "Employee rostering problem optimisation using Planner. Assigns employees to shifts based on their skill.",
            "publicURIs": [
              {
                "protocol": "git",
                "uri": "git://localhost:9418/MySpace/example-Employee_Rostering"
              },
              {
                "protocol": "ssh",
                "uri": "ssh://localhost:8001/MySpace/example-Employee_Rostering"
              }
            ]
          },
          {
            "name": "Mortgage_Process",
            "spaceName": "MySpace",
            "groupId": "mortgage-process",
            "version": "1.0.0-SNAPSHOT",
            "description": "Getting started loan approval process in BPMN2, decision table, business rules, and forms.",
            "publicURIs": [
              {
                "protocol": "git",
                "uri": "git://localhost:9418/MySpace/example-Mortgage_Process"
              },
              {
                "protocol": "ssh",
                "uri": "ssh://localhost:8001/MySpace/example-Mortgage_Process"
              }
            ]
          }
        ],
        "owner": "admin",
        "defaultGroupId": "com.myspace"
      },
      {
        "name": "MySpace2",
        "description": null,
        "projects": [
          {
            "name": "IT_Orders",
            "spaceName": "MySpace",
            "groupId": "itorders",
            "version": "1.0.0-SNAPSHOT",
            "description": "Case Management IT Orders project",
            "publicURIs": [
              {
                "protocol": "git",
                "uri": "git://localhost:9418/MySpace/example-IT_Orders-1"
              },
              {
                "protocol": "ssh",
                "uri": "ssh://localhost:8001/MySpace/example-IT_Orders-1"
              }
            ]
          }
        ],
        "owner": "admin",
        "defaultGroupId": "com.myspace"
      }
    ]
  4. 在 REST 客户端或 curl 实用程序中,发送另外一个带有以下组件的 API 请求,它向 /spaces/{spaceName}/projects 发送一个 POST 请求,以便在一个空间内创建一个项目。根据您的用例调整任何请求详情。

    对于 REST 客户端:

    • 身份验证 :使用 rest-all 角色输入 Business Central 用户的用户名和密码。
    • HTTP Headers :设置以下标头:

      • 接受:application/json
      • 接受语言:en-US
      • Content-Type:application/json
    • HTTP 方法 :设置为 POST
    • URL :输入知识库 REST API 基本 URL 和端点,如 http://localhost:8080/business-central/rest/spaces/MySpace/projects
    • 请求正文 :添加带有新项目标识数据的 JSON 请求正文:
    {
      "name": "Employee_Rostering",
      "groupId": "employeerostering",
      "version": "1.0.0-SNAPSHOT",
      "description": "Employee rostering problem optimisation using Planner. Assigns employees to shifts based on their skill."
    }

    对于 curl 工具:

    • - U :输入 Business Central 用户的用户名和密码,以及 rest-all 角色。
    • - h :设置以下标头:

      • 接受:application/json
      • 接受语言en-US (如果未定义,则 JVM 中的默认区域设置会反映)
      • Content-Type:application/json
    • -x :设置为 POST
    • URL :输入知识库 REST API 基本 URL 和端点,如 http://localhost:8080/business-central/rest/spaces/MySpace/projects
    • -d :添加一个 JSON 请求正文或文件(@file.json),带有新项目的标识数据:
    curl -u 'baAdmin:password@1' -H "Accept: application/json" -H "Accept-Language: en-US" -H "Content-Type: application/json" -X POST "http://localhost:8080/business-central/rest/spaces/MySpace/projects" -d "{ \"name\": \"Employee_Rostering\", \"groupId\": \"employeerostering\", \"version\": \"1.0.0-SNAPSHOT\", \"description\": \"Employee rostering problem optimisation using Planner. Assigns employees to shifts based on their skill.\"}"
    curl -u 'baAdmin:password@1' -H "Accept: application/json" -H "Accept-Language: en-US" -H "Content-Type: application/json" -X POST "http://localhost:8080/business-central/rest/spaces/MySpace/projects" -d @my-project.json
  5. 执行请求并查看 KIE 服务器响应。

    服务器响应示例(JSON):

    {
      "jobId": "1541017411591-6",
      "status": "APPROVED",
      "spaceName": "MySpace",
      "projectName": "Employee_Rostering",
      "projectGroupId": "employeerostering",
      "projectVersion": "1.0.0-SNAPSHOT",
      "description": "Employee rostering problem optimisation using Planner. Assigns employees to shifts based on their skill."
    }

    如果您遇到请求错误,请检查返回的错误消息并相应地调整您的请求。

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部