BulkReleaseItemsData

View as Markdown

BulkReleaseItemsData

BulkReleaseItemsData holds the release, the action, the locales, the reference flag, and the items of a bulk add-to-release request. Pass it to the ReleaseItems method of BulkOperation.

When to Use This Class: Use this class to add many entries and assets to a release in one request, with typed release items.

Conceptual Role: Acts as the JSON request body of the /bulk/release/items request.

Returns: BulkReleaseItemsData. The release and items of a bulk add-to-release request.

Properties

NameTypeRequiredDefaultDescription
Releasestring?NonullUID of the release. Serialized as release.
Actionstring?NonullRelease action, for example publish or unpublish. Serialized as action.
LocaleList<string>?NonullLocale codes of the items. Serialized as locale.
ReferenceboolNofalseIncludes referenced items when true. Serialized as reference.
ItemsList<BulkReleaseItem>?NonullItems to add. Serialized as items. See BulkReleaseItem.

Class-Level Notes

Serialization.

  • The SDK serializes the model with System.Text.Json and leaves out every property that is null. The SDK does not check the values.

Value-type properties.

  • Reference is a bool, so the SDK always sends it. A model where you do not set it sends false.

Compared with BulkAddItemsData.

Method Index

BulkReleaseItemsData has no methods. Set its properties and pass it as shown in the Class-Level Snippet below.

Class-Level Snippet

The snippet below adds one entry, with its references, to a release for publishing.

using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;

ContentstackClient client = new ContentstackClient();

BulkReleaseItemsData data = new BulkReleaseItemsData()
{
    Release = "<RELEASE_UID>",
    Action = "publish",
    Locale = new List<string> { "<LOCALE_CODE>" },
    Reference = true,
    Items = new List<BulkReleaseItem>
    {
        new BulkReleaseItem() { ContentTypeUid = "<CONTENT_TYPE_UID>", Uid = "<ENTRY_UID>", Version = 2, Locale = "<LOCALE_CODE>", Title = "Spring Sale" }
    }
};

try
{
    ContentstackResponse response = client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>").BulkOperation().ReleaseItems(data, "2.0");
    Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}