The events that invoke different triggers are passed to the function handler in different formats. This topic describes the formats of event objects for different triggers.

Event formats

Trigger type Event format
Event trigger for Object Storage Service (OSS) Event format
HTTP trigger The function signatures for HTTP triggers are Request and Response objects, not event objects. For this reason, HTTP triggers do not have an event format. For more information, see Overview.
Topic trigger for Message Service (MNS) Event format
Trigger for Log Service (SLS) Event format
Tablestore trigger Event format
Event trigger for Alibaba Cloud CDN (CDN) Event formats
Time trigger Event format
IoT trigger IoT Hub sends event content to Function Compute as non-encapsulated IoT Hub message content. For example, the following Java code is used to push messages to an IoT topic:
PubRequest request = new PubRequest();
request.setProductKey("VHo5FRjudkZ");
request.setMessageContent(Base64.getEncoder().encodeToString("{\"hello\":\"world\"}".getBytes()));
request.setTopicFullName("/VHo5FRjudkZ/deviceName/update");
request.setQos(0);
PubResponse response = client.getAcsResponse(request);
System.out.println(response.getSuccess());
System.out.println(response.getErrorMessage());                               

From this sample code, Function Compute receives the following event:

{
  "hello": "world"
}                                

For more information about IoT triggers, see Forward data to Function Compute.

References