batchAddMediaItems method

Future<BatchAddMediaItemsToAlbumResponse> batchAddMediaItems(
  1. BatchAddMediaItemsToAlbumRequest request,
  2. String albumId, {
  3. String? $fields,
})

Adds one or more media items in a user's Google Photos library to an album.

The media items and albums must have been created by the developer via the API. Media items are added to the end of the album. If multiple media items are given, they are added in the order specified in this call. Each album can contain up to 20,000 media items. Only media items that are in the user's library can be added to an album. For albums that are shared, the album must either be owned by the user or the user must have joined the album as a collaborator. Partial success is not supported. The entire request will fail if an invalid media item or album is specified.

request - The metadata request object.

Request parameters:

albumId - Required. Identifier of the Album that the media items are added to. Value must have pattern ^\[^/\]+$.

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

Completes with a BatchAddMediaItemsToAlbumResponse.

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<BatchAddMediaItemsToAlbumResponse> batchAddMediaItems(
  BatchAddMediaItemsToAlbumRequest request,
  core.String albumId, {
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  final url_ =
      'v1/albums/' + core.Uri.encodeFull('$albumId') + ':batchAddMediaItems';

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