New REST endpoints on Business Central

REST API has now branch management support

Photo by Nina Ž. on Unsplash

Maven Options

Common maven actions for projects in Business Central can be triggered by REST API and offer a branch optional parameter on version 7.31.0.

We can make great integrations to compile, install, test and deploy automatically with any branch and project without the User Interface.

Use the old endpoints for the master branch or make a POST request to the new endpoints to specify the target branch.

Branch Management

Business Central version 7.32.0 adds REST endpoints to manage branches along with projects and spaces.

We can now get, add or remove branches and all clients gets a refreshed User Interface.

Cheat Sheet

The base URL for the endpoints below is

  • Compile branch: POST
  • Install branch: POST
  • Test branch: POST
  • Deploy branch: POST
  • Get branches: GET
  • Add branch: POST
  • Remove branch: DELETE

To add a branch, send data in JSON format:

{
"newBranchName": "branch01",
"baseBranchName": "master"
}

Examples

In Business Central, the REST API works asynchronously, which means the user does not have to wait the request to be completed. Each request is considered a Job and gets an ID assigned. Jobs can be pulled from server to check status, outputs and possible error messages.

  1. Download Wildfly 18.0.1.Final here
  2. Download Business Central version ≥ 7.32.0 here
  3. Deploy Business Central war file to Wildfly:
$ unzip wildfly-18.0.1.Final.zip$ cp business-central-7.31.0.Final-wildfly14.war \
wildfly-18.0.1.Final/standalone/deployments

4. Add a user with REST role:

$ ./wildfly-18.0.1.Final/bin/add-user.sh -a            \
--user bc \
--password bc \
--role admin,rest-all

5. Increase JVM memory:

$ sed -i -e 's/-Xms64m/-Xms128m/' \
wildfly-18.0.1.Final/bin/standalone.conf
$ sed -i -e 's/-Xmx512m/-Xmx1024m/' \
wildfly-18.0.1.Final/bin/standalone.conf

6. Start Wildfly:

$ ./wildfly-18.0.1.Final/bin/standalone.sh -c standalone-full.xml

7. Create a Space:

$ curl -X POST                                  \
-u 'bc:bc' \
-H "content-type: application/json" \
-d '{"name": "Space123", "owner": "bc"}' \
"http://127.0.0.1:8080/business-central-7.32.0.Final-wildfly14/rest/spaces/"

The CURL utility is used here in a but any REST client would work.

We got the response below:

{
"jobId": "1576173848604-1",
"status": "APPROVED",
"spaceName": "Space123",
"owner": "bc",
"defaultGroupId": null,
"description": null
}

The status means that the request was accepted and put on queue to be processed. We can query jobs by ID to find out its completion status and messages:

$ curl -X GET     \
-u 'bc:bc' \
"http://127.0.0.1:8080/business-central-7.32.0.Final-wildfly14/rest/jobs/1576173848604-1"
{
"status": "SUCCESS",
"jobId": "1576173848604-1",
"result": "Space Space123 is created successfully.",
"lastModified": 1576173848642,
"detailedResult": null
}

8. Create a project:

$ curl -X POST                             \
-u 'bc:bc' \
-H "content-type: application/json" \
-d '{"name": "ProjABC"}' \
"http://127.0.0.1:8080/business-central-7.32.0.Final-wildfly14/rest/spaces/Space123/projects"

Notice that we added to REST endpoint to match the space resource we created on step 7. This applies to all endpoints in Business Central.

9. Get, add, compile and remove branches:

# Get branches
$ curl -X GET \
-u 'bc:bc' \
"http://127.0.0.1:8080/business-central-7.32.0.Final-wildfly14/rest/spaces/Space123/projects/ProjABC/branches"
[{"name":"master"}]# Add branch
$ curl -X POST \
-u 'bc:bc' \
-H "content-type: application/json" \
-d '{"newBranchName": "b1", "baseBranchName": "master"}' \
"http://127.0.0.1:8080/business-central-7.32.0.Final-wildfly14/rest/spaces/Space123/projects/ProjABC/branches"
{
"jobId": "1576175811141-3",
"status": "APPROVED",
"spaceName": "Space123",
"projectName": "ProjABC",
"newBranchName": "b1",
"baseBranchName": "master",
"userIdentifier": "bc"
}
# Check Job
$ curl -X GET \
-u 'bc:bc' \
"http://127.0.0.1:8080/business-central-7.32.0.Final-wildfly14/rest/jobs/1576175811141-3"
{
"status": "SUCCESS",
"jobId": "1576175811141-3",
"result": null,
"lastModified": 1576175811204,
"detailedResult": null
}
# Get branches
$ curl -X GET \
-u 'bc:bc' \
"http://127.0.0.1:8080/business-central-7.32.0.Final-wildfly14/rest/spaces/Space123/projects/ProjABC/branches"
[
{"name": "b1"},
{"name": "master"}
]
# Compile branch
$ curl -X POST \
-u 'bc:bc' \
"http://127.0.0.1:8080/business-central-7.32.0.Final-wildfly14/rest/spaces/Space123/projects/ProjABC/branches/b1/maven/compile"
{
"jobId": "1576175811233-4",
"status": "APPROVED",
"spaceName": "Space123",
"projectName": "ProjABC",
"branchName": "b1",
}
# Check Job
$ curl -X GET \
-u 'bc:bc' \
"http://127.0.0.1:8080/business-central-7.32.0.Final-wildfly14/rest/jobs/1576175811233-4"
{
"status": "SUCCESS",
"jobId": "1576175811233-4",
"result": null,
"lastModified": 1576175811257,
"detailedResult": null
}
# Remove branch
$ curl -X DELETE \
-u 'bc:bc' \
"http://127.0.0.1:8080/business-central-7.32.0.Final-wildfly14/rest/spaces/Space123/projects/ProjABC/branches/b1"
{
"jobId": "1576175811421-5",
"status": "APPROVED",
"spaceName": "Space123",
"projectName": "ProjABC",
"branchName": "b1",
"userIdentifier": "bc"
}
# Check Job
$ curl -X GET \
-u 'bc:bc' \
"http://127.0.0.1:8080/business-central-7.32.0.Final-wildfly14/rest/jobs/1576175811421-5"
{
"status": "SUCCESS",
"jobId": "1576175811421-5",
"result": null,
"lastModified": 1576175811452,
"detailedResult": null
}
# Get branches
$ curl -X GET \
-u 'bc:bc' \
"http://127.0.0.1:8080/business-central-7.32.0.Final-wildfly14/rest/spaces/Space123/projects/ProjABC/branches"
[{"name":"master"}]

kie-tooling

Tooling Team from kie.org

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store