Skip to main content

Implementation

Implement the FairCom Edge API actions for REST connectors

Abstract

FairCom provides particular API actions for REST connectors

FairCom provides particular API actions for REST connectors.

Note

The FairCom server must be configured to enable the REST service before REST API actions can be performed.

See "createOutput" for definitions of the "params" properties. See Outputs for additional information on JSON output actions.

Examples

Minimal

Request

{
  "authToken":"' + token + ’",
  "api":"hub",
  "action":"createOutput",
  "params":{
     "outputName":"rest1",
     "tableName":"modbusTableTCP",
     "serviceName":"rest",
     "settings":{
        "host":"127.0.0.1:1880",
        "uri":"/equipment/2/alert",
        "body":[
           {
              "propertyPath":"Temperature",
              "propertyValue":{
                 "fromSourcePropertyPath":{
                    "formatString":"<%temperature%>"
                 }
              }
           }
        ]
     }
  }
}

Response

{  Temperature: "103" }

Request

{
  "authToken":"' + token + ’",
  "api":"hub",
  "action":"createOutput",
  "params":{
    "outputName":"rest1",
    "tableName": "modbusTableTCP",
    "serviceName":"rest",
    "settings":{
      "host": "127.0.0.1:1880",
      "uri": "/equipment/2/alert",
      "headers":[
        "tenantId: 99,01",
        "X-erp-module: MNT"
      ],
      "body":[
        {
          "propertyPath": "equipment",		
          "propertyValue": {"fromConstant": "0002"}
        },
        {
          "propertyPath": "description",
          "propertyValue": {
           "fromSourcePropertyPath": {
              "formatString": "Temperature is too high. Please, verify. Temperature = <%temperature%>."
            }
          }
        }
      ],
      "threshold":{
        "expression": "temperature > 60"
      }
    }
  }
}

Response

This is the result when the "temperature" property value is greater than 60:

{
  equipment: "0002",
  description: "Temperature is too high. Please, verify. Temperature = 103."
}