Get Event¶
Get the details of an event via eventId
.
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 |
|
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": "电流阈值",
"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": "电量"
}
}
}
}
}
Java SDK Sample¶
package com.envisioniot.enos.api.sample.connect_service.event;
import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;
import com.envisioniot.enos.connect_service.v2_1.event.GetEventRequest;
import com.envisioniot.enos.connect_service.v2_1.event.GetEventResponse;
import com.google.gson.Gson;
public class GetEvent {
public static void main(String[] args) {
String appKey = "yourAppKey";
String appSecret = "yourAppSecret";
GetEventRequest request = new GetEventRequest();
request.setOrgId("yourOrgId");
request.setEventId("yourEventId");
request.setResolveName(true);
try {
GetEventResponse response = Poseidon.config(PConfig.init().appKey(appKey).appSecret(appSecret).debug())
.url("yourServerUrl")
.getResponse(request, GetEventResponse.class);
Gson gson = new Gson();
System.out.println(gson.toJson(response));
} catch (Exception e) {
System.out.print(e);
}
}
}