V2.1 Get Event


Get the details of an event via eventId.


This API is available in EnOS 2.1.0 and above.

If you need to invoke this API after performing bulk updates to relevant events using other APIs, it is recommended to wait for about 2 seconds to avoid obtaining unupdated data.

Request Format

GET https://{apigw-address}/connect-service/v2.1/events?action=get

Request Parameters (URI)

Name

Location (Path/Query)

Mandatory/Optional

Data Type

Description

orgId

Query

Mandatory

String

The organization ID which the asset belongs to. How to get orgId>>

eventId

Query

Mandatory

String

The event ID.

resolveName

Query

Optional

Boolean

  • true: Restructures the data from output and returns eventName and outputNames.

  • false (default): Does not restructure the data from output. eventName and outputNames values will be blank.

Response Parameters

Name

Data Type

Description

data

Event Struct

The details of the event. See Event Struct.

Event Struct

Name

Data Type

Description

orgId

String

The organization ID which the asset belongs to.

eventId

String

The event ID.

productKey

String

The product key.

deviceKey

String

The device key.

assetId

String

The asset ID.

tslEventKey

String

The event key in the TSL model.

tslEventType

String

The event type defined in the TSL model.

output

String

The event output.

outputData

Map (Key is of String type, and Value is of Object)

The output in JSON.

timestamp

Long

The event timestamp.

localtime

String

The local time when the event occurs.

eventName

StringI18n

The event name. For more details on the structure and locales supported, see Internationalized name struct.

outputNames

Map (Key is of String type, and Value is of StringI18n)

The names of the event output.

Samples

Request Sample

url: https://{apigw-address}/connect-service/v2.1/events?action=get&eventId=yourEventId&orgId=yourOrgId&resolveName=true
method: GET

Return Sample

{
  "code": 0,
  "msg": "OK",
  "requestId": "437f3075-448c-4995-9bf5-81e15382615c",
  "data": {
    "eventId": "20210323d3a7738134ae8a33f569d4fea8f4d57c",
    "orgId": "yourOrgId",
    "productKey": "yourProductKey",
    "deviceKey": "yourDeviceKey",
    "assetId": "yourAssetId",
    "tslEventKey": "yourEventKey",
    "tslEventType": "INFO",
    "output": "{\"test\":12,\"branchCurr\":[1.1,2.1,3.1],\"Power\":11.1}",
    "outputData": {
      "test": 12,
      "branchCurr": [
          1.1,
          2.1,
          3.1
      ],
      "Power": 11.1
    },
    "timestamp": 1616493875000,
    "localtime": "2021-03-23 18:04:35",
    "eventName": {
      "defaultValue": "currentThreshold",
      "i18nValue": {
          "en_US": "",
          "zh_CN": ""
      }
    },
    "outputNames": {
      "test": {
        "defaultValue": "test",
        "i18nValue": {
            "en_US": "test",
            "zh_CN": "测试"
        }
      },
      "branchCurr": {
        "defaultValue": "branchCurr",
        "i18nValue": {
            "en_US": "branchCurr",
            "zh_CN": "当前分支"
        }
      },
      "Power": {
        "defaultValue": "Power",
        "i18nValue": {
            "en_US": "Power",
            "zh_CN": "电量"
        }
      }
    }
  }
}

SDK Samples


You can access the SDK samples for Connection Service on GitHub: