Cumulocity Event Language - Calling an External API

The form that I see in your documentation can query the database for more data when writing CEL, but is it possible to call an external API? It is also possible to update a dimension to fill in a missing value.

For example, if I want to update a dimension by adding the "alt" value of the "c8y_Position" segment, calling the specific API: https://maps.googleapis.com/maps/api/elevation/json?locations=40.714728,-73.998672

Is it possible to write such a statement:

expression string js:getElevation(lng, lat) [
    function request(lng, lat, callback) {
    var xobj = new XMLHttpRequest();
    // true parameter denotes asynchronous
    xobj.open('GET', 'https://maps.googleapis.com/maps/api/elevation/json?locations=' + lat + ', ' + lng + ', true);
    xobj.onreadystatechange = function () {
            if (xobj.readyState == 4 && xobj.status == "200") {
                callback(xobj.responseText);
            }
        };
        xobj.send(null);
    }
    request(lng, lat, function (data) {
        return data.results.elevation;
    });
]
insert into UpdateMeasurement
select
  e.id as id,
  getElevation(
    getNumber(e, "c8y_Position.lng.value"),
    getNumber(e, "c8y_Position.lat.value")
   ) as c8y_Position.alt
from MeasurementCreated e

Is it possible to perform such processing. Do you have more samples or documentation on CEL?

+4
source share
3 answers

, Lambda Cumulocity REST API Amazon - (AWS) . - AWS/Lambda . :

  • AWS Lambda, , Cumulocity API REST.

  • CEL Cumulocity .

+1

Cumulocity.

Currently, you are limited to the built-in services that will connect to, for example, sms or phone calls

0
source

Source: https://habr.com/ru/post/1627957/


All Articles