This documentation supports the 20.08 version of BMC Helix Platform. 
To view an earlier version, select 20.02 from the Product version menu.

Creating a custom interface with REST

You can use REST APIs for a client to communicate with your custom bundle deployed in BMC Helix Platform server. The REST API uses the base URL for the web service, such as https://<host>:<port>/api/

Each API is called by issuing a standard HTTP request method: POST, GET, PUT, or DELETE (more commonly known as the CRUD operations: Create, Read, Update, and Delete).

The client creates new resources by issuing POST requests. The details of an individual resource are retrieved using a GET request. The client issues PUT requests to modify a resource object. When a resource is no longer needed, the client issues a DELETE request to remove the resource.

Communicating with BMC Helix Platform server by using REST API

You can use REST APIs for clients to communicate with BMC Helix Platform server. The following table lists the APIs that can be used for login and records:

API typeDescriptionAction
User and AuthenticateAuthenticate UserPOST
Get UserGET
Logout UserPOST
RecordsCreate record definitionPOST
Get Record DefinitionGET
Get Record Definition Data PageGET
Get Record New Record InstanceGET
Create Record InstancePOST
Get Record Instance Data PageGET
Delete Record DefinitionDELETE

For more information on REST APIs, see API documentation.

For example:

You can define a service named lxDishDataPageResource, which connects the Restful API Get Record Definition Data Page.

(function  () {
   'use strict';
    angular.module('lunch-order.home').factory('lunchOrderLxDishDataPageResource', function  (rxRecordInstanceDataPageResource, DISHES) {
       return  rxRecordInstanceDataPageResource.withName(DISHES.definitionName);
    });
})();

To get the data, use the following code:

lxDishDataPageResource.get().then(function  (dataPage) {
    $scope.dishes = _.map(dataPage.data, function (dish) {
        return {
            dish: dish[DISHES.fields.dish],
            description: dish[DISHES.fields.description],
            price: dish[DISHES.fields.price],
            quantity: 0
        };
    });
});

Sample REST API

The following sample code illustrates how to use a REST API in your Java code:

The class WorkOrderCostResource implements rx.service.common.RestfulResource. It is annotated with @Path that describes the URL prefix @Path(“example/workordercost”). It contains a get() method annotated with HTTP verb @GET and an authorization directive.

package
com.example.resource;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import
javax.ws.rs.PathParam;
import com.bmc.arsys.rx.application.common.ServiceLocator;
import com.bmc.arsys.rx.services.bundle.BundleService;
import com.bmc.arsys.rx.services.common.RestfulResource;
import com.bmc.arsys.rx.services.common.annotation.AccessControlledMethod;
import com.bmc.arsys.rx.services.common.annotation.AccessControlledMethod.AuthorizationLevel;
import com.bmc.arsys.rx.services.common.annotation.RxDefinitionTransactional;
import com.example.service.WorkOrderService;
 
/**
 * The Class WorkOrderCost
 */
@Path("example/workordercost")
public class WorkOrderCostResource implements RestfulResource {
        private WorkOrderService workOrderService = null;
   /**
    * Gets the cost associated with a work order.
    *
    * @return the cost.
   */
 
   @GET
   @Path("/{workorderid}")
   @RxDefinitionTransactional(readOnly = true)
   @AccessControlledMethod(authorization = AuthorizationLevel.ValidUser) 
   public String get(@PathParam("workorderid") String workOrderId) {
      StringBuilder response = new StringBuilder();
      Integer cost = getWorkOrderService().getCost(workOrderId);
      response.append("{workorder:\"");
      response.append(workOrderId);
      response.append("\", cost:\"");
      response.append(cost);
      response.append("\"}");
      return response.toString();
   }
  
private WorkOrderService getWorkOrderService() {
   if (workOrderService == null) {
      BundleService bundleService = ServiceLocator.getBundleService();
      workOrderService = (WorkOrderService)
      bundleService.getService("com.example.service.WorkOrderService");
   }
 
   return workOrderService;
   }
}

To test this, you can use a custom client, a generic REST client such as POSTMAN or, since this is a GET operation, you can use the browser URL directly (as long as the browser is logged in to an active session). The URL syntax is:

https://<host>:<port>/api/bundle-id/url-path (followed by any URL parameters).

For the above sample code, the following image shows how to test it in POSTMAN:

Related topics

API documentation 

Enabling and downloading logs from BMC Helix Innovation Studio

Enabling browser logging in a Digital Service application

Was this page helpful? Yes No Submitting... Thank you

Comments