batchPutMessage method
Sends messages to a channel.
May throw ResourceNotFoundException. May throw InvalidRequestException. May throw InternalFailureException. May throw ServiceUnavailableException. May throw ThrottlingException.
Parameter channelName
:
The name of the channel where the messages are sent.
Parameter messages
:
The list of messages to be sent. Each message has the format: {
"messageId": "string", "payload": "string"}.
The field names of message payloads (data) that you send to AWS IoT Analytics:
- Must contain only alphanumeric characters and undescores (_). No other special characters are allowed.
- Must begin with an alphabetic character or single underscore (_).
- Cannot contain hyphens (-).
- In regular expression terms: "^[A-Za-z_]([A-Za-z0-9]*|[A-Za-z0-9][A-Za-z0-9_]*)$".
- Cannot be more than 255 characters.
- Are case insensitive. (Fields named foo and FOO in the same payload are considered duplicates.)
Implementation
Future<BatchPutMessageResponse> batchPutMessage({
required String channelName,
required List<Message> messages,
}) async {
ArgumentError.checkNotNull(channelName, 'channelName');
_s.validateStringLength(
'channelName',
channelName,
1,
128,
isRequired: true,
);
ArgumentError.checkNotNull(messages, 'messages');
final $payload = <String, dynamic>{
'channelName': channelName,
'messages': messages,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/messages/batch',
exceptionFnMap: _exceptionFns,
);
return BatchPutMessageResponse.fromJson(response);
}