第 7 章 BUSINESS CENTRAL スペースおよびプロジェクト用のナ レッジストア REST API
7.1. REST クライアントまたは CURL ユーティリティーを使用した ナレッジ ストア REST API による要求送信
ナレッジストア REST API を使用すると、Business Central ユーザーインターフェースを使わずに Red
Hat Process Automation Manager のプロジェクトやスペースを操作することができます。ナレッジス
トア REST API 要求は、REST クライアントまたは curl ユーティリティーを使って送信できます。
前提条件 前提条件
Business Central をインストールし、実行している。
rest-all ユーザーロールで Process Server にアクセスできる。
手順 手順
1. 要求の送信先となる関連する API endpoint を特定します。Business Central からスペースを取 得する [GET] /spaces などです。
{
"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."
}
2. REST クライアントまたは curl ユーティリティーで、/spaces への GET要求に以下のコンポー ネントを記入します。ご自分のユースケースに合わせて、要求詳細を調整します。
REST クライアントの場合:
Authentication: rest-all ロールを持つ Business Central ユーザーのユーザー名とパスワー ドを入力します。
HTTP Headers: 以下のヘッダーを設定します。
Accept: application/json HTTP method: GET に設定します。
URL: Process Server REST API ベース URL とエンドポイントを入力します。たとえ ば、http://localhost:8080/business-central/rest/spaces となります。
curl ユーティリティーの場合:
-u: rest-all ロールを持つ Business Central ユーザーのユーザー名とパスワードを入力しま す。
-H: 以下のヘッダーを設定します。
accept: application/json -X: GET に設定します。
URL: Process Server 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 Server の応答を確認します。
サーバー応答の例 (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"
4. REST クライアントまたは curl ユーティリティーで、/spaces/{spaceName}/projects への
POST 要求を以下のコンポーネントで送信し、スペース内でプロジェクトを作成します。ご自
分のユースケースに合わせて、要求詳細を調整します。
REST クライアントの場合: }
] }, {
"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"
} ]
Authentication: rest-all ロールを持つ Business Central ユーザーのユーザー名とパスワー ドを入力します。
HTTP Headers: 以下のヘッダーを設定します。
Accept: application/json Content-Type: application/json HTTP method: POST に設定します。
URL: Process Server REST API ベース URL とエンドポイントを入力します。たとえ
ば、http://localhost:8080/business-central/rest/spaces/MySpace/projects となります。
要求のボディー
要求のボディー: 新規プロジェクト用の ID データのある JSON 要求ボディーを追加しま す。
curl ユーティリティーの場合:
-u: rest-all ロールを持つ Business Central ユーザーのユーザー名とパスワードを入力しま す。
-H: 以下のヘッダーを設定します。
accept: application/json content-type: application/json -X: POST に設定します。
URL: Process Server REST API ベース URL とエンドポイントを入力します。たとえ
ば、http://localhost:8080/business-central/rest/spaces/MySpace/projects となります。
-d: 新規プロジェクト用の ID データのある JSON 要求ボディーまたはファイル (@file.json) を追加します。
curl -u 'baAdmin:password@1' -H "accept: application/json" -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 "content-type:
application/json" -X POST "http://localhost:8080/business-central/rest/spaces/MySpace/projects" -d @my-project.json 5. 要求を実行し、KIE Server の応答を確認します。
{
"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."
}
エラーが発生した場合は、返されたエラーメッセージを確認して、それに応じて要求を調整し ます。