Creating an 'Custom Apama Rule' application via REST Services

This article describes how to create a Cumulocity application of type 'Custom Apama Rule' via REST calls rather than from GUI.


1. Install Postman

2. You need to have an access to cumulocity tenant having all permissions/subscriptions to features shown in this article.

Create device and send measurements using Simulator

From Device Management, goto Devices > Simulators. Click on 'New Simulator' and select 'Temperature Measurements' and click on Create.

Once Simulator is created, select switch so that Simulator state changes from 'paused' to 'running'. Also one can verify that a device named 'Temperature #1' has been created under Devices > 'All devices' and temperature measurements are appearing in measurements tab.

Import REST collection to postman

Refer my other article ( Section: Pre requisite (Setup Postman for Cumulocity REST calls), with only difference do not follow step #2, but instead click on Import button in postman and choose the attached .json file.

Run REST services from imported collection to create 'Custom Apama Rule' application

1. Create Application

Run the first REST request providing name and key. Default names are already given, you can continue with same.

Once the request is successful, an application with the given name is GUI would be present at Administration > Applications > Own Applications. Note Application ID and in the Archives tab, there are no files.

2. Get App ID

Run the second REST request providing App name in URL. Default names are already given, you can continue with the same. Make a note of Application ID from Response.

3. Upload Monitor File

Run the third REST request providing Application ID in URL and choosing .mon file to be uploaded from body. Make a note of 'Activate Version ID' from Response headers.

Verify now Archives tab of application has a uploaded .mon file, but file is not active. 

4. Activate uploaded Monitor File

Important Note: This forth REST request has been extracted from backend calls happening on GUI, when service is being activated. This is a NOT SUPPORTED REST API either from Cumulocity RnD. So might change in future without any intimation.

Run the forth REST request providing Application ID in URL and 'Activate Version ID' noted from earlier response in body of this request.

On successful execution of this request, .mon file available in Archives tab of Apama application, it shows Active status.

Also once Rule becomes active, one could see new measurements 'c8y_FarenMeasurement' this rule is generating from Device management > All devices > 'Temperature #1' Farenheit measurements are appearing in measurements tab along with Temperature Measurements in celcius.

TempRulesArchiveExtractIt.7z (659 Bytes)

Postman REST Collection for Importing Extract It.7z (1.22 KB)