BulkAddItem
BulkAddItem
BulkAddItem identifies one entry or asset in a bulk release request. Add it to BulkAddItemsData.Items before you call the AddItems, AddItemsWithDeployment, UpdateItems, and UpdateItemsWithDeployment methods.
When to Use This Class: Use this class once for each item that a bulk release request adds to a release.
Conceptual Role: Acts as one object of the items array in the request body.
Returns: BulkAddItem. One item of a bulk release request.
Properties
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| Uid | string? | No | null | UID of the entry or asset. Serialized as uid. |
| ContentType | string? | No | null | UID of the content type. Serialized as content_type. |
| ContentTypeUid | string? | No | null | UID of the content type. Serialized as content_type_uid. |
| Version | int? | No | null | Version of the item. Serialized as version. |
| Locale | string? | No | null | Locale code of the item. Serialized as locale. |
| Title | string? | No | null | Title of the entry. Serialized as title. |
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.
Two content type properties.
- ContentType and ContentTypeUid hold the same value under different JSON keys. The SDK sends each one that is not null.
- The Content Management API (CMA) reference for the Bulk Add to Release request describes items with content type UIDs, entry UIDs, locales, versions, and titles. The CMA Add multiple items to a Release request names this key content_type_uid, so set ContentTypeUid.
Method Index
BulkAddItem 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 to a release with every item property except ContentType set.
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient();
BulkAddItemsData data = new BulkAddItemsData()
{
Release = "<RELEASE_UID>",
Action = "publish",
Locale = new List<string> { "<LOCALE_CODE>" },
Reference = true,
Items = new List<BulkAddItem>
{
new BulkAddItem() { Uid = "<ENTRY_UID>", ContentTypeUid = "<CONTENT_TYPE_UID>", Version = 2, Locale = "<LOCALE_CODE>", Title = "Spring Sale" }
}
};
try
{
ContentstackResponse response = client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>").BulkOperation().AddItems(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}");
}