This documentation supports the 23.3 version of BMC Helix Innovation Suite (AR System and BMC Helix Innovation Studio).

To view an earlier version, select the version 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 the BMC Helix Innovation Studio. The REST API uses the base URL for the web service, such as https://<host>:<port>/api/

The client issues the following standard HTTP request method to call an API:

  • POST requests to create new resources
  • GET requests to retrieve details of individual resources
  • PUT requests to modify a resource object
  • DELETE requests to remove the resources no longer needed

These are more commonly known as the CRUD operations: Create, Read, Update, and Delete.

Communicating with BMC Helix Innovation Studio by using REST API

You can use REST APIs for clients to communicate with the BMC Helix Innovation Studio. The following table lists the APIs that you can use 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 the 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 operation, you can use:

  • A custom client
  • A generic REST client such as POSTMAN 
  • The browser URL directly (as long as the browser session is active) because this is a GET operation. The URL syntax is: https://<host>:<port>/api/bundle-id/url-path (followed by any URL parameters).

Here is an example to test the sample code in POSTMAN:

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

Comments