patch method

Future<Message> patch(
  1. Message request,
  2. String name, {
  3. bool? allowMissing,
  4. String? updateMask,
  5. String? $fields,
})

Updates a message.

There's a difference between the patch and update methods. The patch method uses a patch request while the update method uses a put request. We recommend using the patch method. For an example, see Update a message. Requires authentication. Supports app authentication and user authentication. When using app authentication, requests can only update messages created by the calling Chat app.

request - The metadata request object.

Request parameters:

name - Resource name of the message. Format: spaces/{space}/messages/{message} Where {space} is the ID of the space where the message is posted and {message} is a system-assigned ID for the message. For example, spaces/AAAAAAAAAAA/messages/BBBBBBBBBBB.BBBBBBBBBBB. If you set a custom ID when you create a message, you can use this ID to specify the message in a request by replacing {message} with the value from the clientAssignedMessageId field. For example, spaces/AAAAAAAAAAA/messages/client-custom-name. For details, see Name a message. Value must have pattern ^spaces/\[^/\]+/messages/\[^/\]+$.

allowMissing - Optional. If true and the message isn't found, a new message is created and updateMask is ignored. The specified message ID must be [client-assigned](https://developers.google.com/workspace/chat/create-messages#name_a_created_message) or the request fails.

updateMask - Required. The field paths to update. Separate multiple values with commas or use * to update all field paths. Currently supported field paths: - text - attachment - cards (Requires [app authentication](/chat/api/guides/auth/service-accounts).) - cards_v2 (Requires [app authentication](/chat/api/guides/auth/service-accounts).)

  • accessory_widgets (Requires [app authentication](/chat/api/guides/auth/service-accounts).)

$fields - Selector specifying which fields to include in a partial response.

Completes with a Message.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<Message> patch(
  Message request,
  core.String name, {
  core.bool? allowMissing,
  core.String? updateMask,
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if (allowMissing != null) 'allowMissing': ['${allowMissing}'],
    if (updateMask != null) 'updateMask': [updateMask],
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'v1/' + core.Uri.encodeFull('$name');

  final response_ = await _requester.request(
    url_,
    'PATCH',
    body: body_,
    queryParams: queryParams_,
  );
  return Message.fromJson(response_ as core.Map<core.String, core.dynamic>);
}