ReleaseItem
ReleaseItem
The ReleaseItem class lists, adds, and removes the entries and assets of one release, and moves them to their latest versions before you deploy.
When to Use This Class: Use this class to fill a release with the entries and assets that go live together. Check its contents before you deploy it.
Conceptual Role: Acts as the Content Management API (CMA) client for the /releases/<RELEASE_UID>/items endpoint. Call Item on a Release to get an instance.
Returns: ReleaseItem. A handle for the items of one release.
Instance State
You get an instance only through stack.Release("<RELEASE_UID>").Item(), so every instance belongs to one release. Every method of the class works on that release. The Method Index below lists them.
stack.Release().Item(), with no release UID, throws ArgumentException before you get an instance.
Class-Level Notes
Authentication.
- stack.Release() throws InvalidOperationException when the client has no authtoken and the Stack has no management token, and when the Stack has no API key.
- The CMA reference lists both the authtoken and the management token (authorization) for every release item request. When the Stack has a management token, the SDK sends it instead of the client's authtoken.
Describe each item with ReleaseItemModel.
- ReleaseItemModel holds the UID, version, locale, content type UID, and action of one entry or asset.
- The CMA reference identifies an asset with the content type UID built_io_upload.
Branch.
- The branchUid argument of client.Stack() adds a branch header to every request from that Stack.
Errors and responses.
- The SDK throws ContentstackErrorException when the API returns an error status. Read StatusCode, ErrorCode, ErrorMessage, and Errors on the exception to see what the API rejected.
- Every method returns the raw API response as a ContentstackResponse. Read the body with OpenJsonObjectResponse().
- Each async method runs its client-side checks when you call it and throws before it returns a task. await every async method so that a catch (ContentstackErrorException) block receives API errors.
Rate Limiting & Retry.
- This SDK automatically retries on 429 with configurable delay and attempt limits.
Additional Resource For more information on retry limits and delays, refer to the ContentstackClientOptions documentation.
Capability Matrix
| Capability | Supported | Notes / Alternative |
|---|---|---|
| Add one item through the single-item path | No | Create sends the item to the /items path. Call CreateMultiple with a one-item list for the request shape the CMA reference documents for /items. |
| Update one item to its latest version | No | UpdateReleaseItem updates every item of the release at once. |
| Add items from several releases in one call | No | Use the bulk add to release operation of the BulkOperation class. |
Method Index
Work with the items of one release. Available on stack.Release("<RELEASE_UID>").Item().
| Method Name | Returns | Description |
|---|---|---|
| GetAll | The API response with the items of the release. | Lists the entries and assets of the release. |
| GetAllAsync | The API response with the items of the release. | Lists the items asynchronously. |
| Create | The API response for the added item. | Adds one entry or asset to the release. |
| CreateAsync | The API response for the added item. | Adds one item asynchronously. |
| CreateMultiple | The API response for the added items. | Adds several entries and assets to the release. |
| CreateMultipleAsync | The API response for the added items. | Adds several items asynchronously. |
| UpdateReleaseItem | The API response for the version update. | Moves every item to its latest version. |
| UpdateReleaseItemAsync | The API response for the version update. | Moves every item to its latest version asynchronously. |
| Delete | The API response for the removed items. | Removes entries and assets from the release. |
| DeleteAsync | The API response for the removed items. | Removes items asynchronously. |
Class-Level Snippet
The snippet below adds an entry and an asset to a release, moves every item to its latest version, and lists the items.
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
ReleaseItem items = client.Stack("<API_KEY>").Release("<RELEASE_UID>").Item();
try
{
List<ReleaseItemModel> models = new List<ReleaseItemModel>
{
new ReleaseItemModel { Uid = "<ENTRY_UID>", ContentTypeUID = "<CONTENT_TYPE_UID>", Version = 2, Locale = "en-us", Action = "publish" },
new ReleaseItemModel { Uid = "<ASSET_UID>", ContentTypeUID = "built_io_upload", Version = 1, Locale = "en-us", Action = "publish" }
};
items.CreateMultiple(models);
items.UpdateReleaseItem(new List<string> { "$all" });
ContentstackResponse response = items.GetAll();
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects a request, for example an unknown entry version
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}Methods
Each method of the ReleaseItem class has its own section below, with its parameters, validation rules, behavior, and examples.
Create
Create adds one entry or asset to the release that the ReleaseItem object belongs to.
| Name | Type | Description |
|---|---|---|
| model (required) | ReleaseItemModel | UID, version, locale, content type, and action of the item. |
| collection | ParameterCollection? | Adds query parameters, for example include_branch. |
Returns: ContentstackResponse. The API response for the added item.
Validation
- Throws ArgumentNullException (parameter dataModel) if model is null, before any request.
- The SDK does not check the properties of model. An entry that does not exist, or a version it does not have, reaches the API, and the SDK throws the rejection as ContentstackErrorException.
- collection set to null sends no query parameters.
- Throws ContentstackErrorException when the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Sends one POST request to /releases/<RELEASE_UID>/items with the body {"item": {...}}, and the entries of collection as query parameters.
- The Content Management API reference documents two requests for adding items:
- Add a single item to a Release uses the /item path.
- Add multiple items to a Release uses the /items path, which Create sends to, with the items under an items key.
- For the request shape the API reference documents on /items, call CreateMultiple with a one-item list.
- The body holds every ReleaseItemModel property that is not null. version is always present, 0 unless you set it.
- Returns the raw API response.
Example
Basic usage: add an entry to a release
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
ReleaseItemModel model = new ReleaseItemModel
{
Uid = "<ENTRY_UID>",
ContentTypeUID = "<CONTENT_TYPE_UID>",
Version = 2,
Locale = "en-us",
Action = "publish"
};
try
{
ContentstackResponse response = client.Stack("<API_KEY>").Release("<RELEASE_UID>").Item().Create(model);
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}");
}All parameters: add an asset with a branch key in the response
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient();
ReleaseItemModel model = new ReleaseItemModel
{
Uid = "<ASSET_UID>",
ContentTypeUID = "built_io_upload",
Version = 1,
Locale = "en-us",
Action = "publish"
};
ParameterCollection collection = new ParameterCollection();
collection.Add("include_branch", true);
try
{
ContentstackResponse response = client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>").Release("<RELEASE_UID>").Item().Create(model, collection);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}CreateAsync
CreateAsync adds one entry or asset to the release that the ReleaseItem object belongs to, without blocking the calling thread.
| Name | Type | Description |
|---|---|---|
| model (required) | ReleaseItemModel | UID, version, locale, content type, and action of the item. |
| collection | ParameterCollection? | Adds query parameters, for example include_branch. |
Returns: Task<ContentstackResponse>. The API response for the added item.
Validation
- Throws ArgumentNullException (parameter dataModel) if model is null. The SDK throws it when you call CreateAsync, before it returns a task.
- collection set to null sends no query parameters.
- Throws ContentstackErrorException when the API rejects the request. The exception surfaces when you await the task.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Sends the same POST request to /releases/<RELEASE_UID>/items as Create and completes the task when the API responds.
- Otherwise behaves like Create.
Example
Basic usage: add an entry to a release
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
ReleaseItemModel model = new ReleaseItemModel
{
Uid = "<ENTRY_UID>",
ContentTypeUID = "<CONTENT_TYPE_UID>",
Version = 2,
Locale = "en-us",
Action = "publish"
};
try
{
ContentstackResponse response = await client.Stack("<API_KEY>").Release("<RELEASE_UID>").Item().CreateAsync(model);
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}");
}All parameters: add an asset with a branch key in the response
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient();
ReleaseItemModel model = new ReleaseItemModel
{
Uid = "<ASSET_UID>",
ContentTypeUID = "built_io_upload",
Version = 1,
Locale = "en-us",
Action = "publish"
};
ParameterCollection collection = new ParameterCollection();
collection.Add("include_branch", true);
try
{
ContentstackResponse response = await client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>").Release("<RELEASE_UID>").Item().CreateAsync(model, collection);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}CreateMultiple
CreateMultiple adds several entries and assets to the release that the ReleaseItem object belongs to, in one request.
| Name | Type | Description |
|---|---|---|
| models (required) | List<ReleaseItemModel> | The entries and assets to add. |
| collection | ParameterCollection? | Adds query parameters, for example include_branch. |
Returns: ContentstackResponse. The API response for the added items.
Validation
- Throws ArgumentNullException (parameter dataModel) if models is null, before any request.
- The SDK does not check the list or its items. An empty list, or an item that names no entry or asset, reaches the API, and the SDK throws the rejection as ContentstackErrorException.
- collection set to null sends no query parameters.
- Throws ContentstackErrorException when the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Sends one POST request to /releases/<RELEASE_UID>/items with the body {"items": [...]}, and the entries of collection as query parameters. See Add multiple items to a Release in the Content Management API reference.
- Each item in the body holds every ReleaseItemModel property that is not null. version is always present, 0 unless you set it.
- The API reference identifies an asset with the content type UID built_io_upload.
- Returns the raw API response.
Example
Basic usage: add an entry and an asset to a release
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
List<ReleaseItemModel> models = new List<ReleaseItemModel>
{
new ReleaseItemModel { Uid = "<ENTRY_UID>", ContentTypeUID = "<CONTENT_TYPE_UID>", Version = 2, Locale = "en-us", Action = "publish" },
new ReleaseItemModel { Uid = "<ASSET_UID>", ContentTypeUID = "built_io_upload", Version = 1, Locale = "en-us", Action = "publish" }
};
try
{
ContentstackResponse response = client.Stack("<API_KEY>").Release("<RELEASE_UID>").Item().CreateMultiple(models);
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}");
}All parameters: add one entry for unpublishing, with a branch key in the response
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient();
List<ReleaseItemModel> models = new List<ReleaseItemModel>
{
new ReleaseItemModel { Uid = "<ENTRY_UID>", ContentTypeUID = "<CONTENT_TYPE_UID>", Version = 3, Locale = "fr-fr", Action = "unpublish" }
};
ParameterCollection collection = new ParameterCollection();
collection.Add("include_branch", true);
try
{
ContentstackResponse response = client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>").Release("<RELEASE_UID>").Item().CreateMultiple(models, collection);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}CreateMultipleAsync
CreateMultipleAsync adds several entries and assets to the release that the ReleaseItem object belongs to, without blocking the calling thread.
| Name | Type | Description |
|---|---|---|
| model (required) | List<ReleaseItemModel> | The entries and assets to add. |
| collection | ParameterCollection? | Adds query parameters, for example include_branch. |
Returns: Task<ContentstackResponse>. The API response for the added items.
Validation
- Throws ArgumentNullException (parameter dataModel) if model is null. The SDK throws it when you call CreateMultipleAsync, before it returns a task.
- collection set to null sends no query parameters.
- Throws ContentstackErrorException when the API rejects the request. The exception surfaces when you await the task.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Names the list parameter model, where CreateMultiple names it models. Use the matching name when you pass it as a named argument.
- Sends the same POST request as CreateMultiple and completes the task when the API responds.
- Otherwise behaves like CreateMultiple.
Example
Basic usage: add an entry and an asset to a release
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
List<ReleaseItemModel> items = new List<ReleaseItemModel>
{
new ReleaseItemModel { Uid = "<ENTRY_UID>", ContentTypeUID = "<CONTENT_TYPE_UID>", Version = 2, Locale = "en-us", Action = "publish" },
new ReleaseItemModel { Uid = "<ASSET_UID>", ContentTypeUID = "built_io_upload", Version = 1, Locale = "en-us", Action = "publish" }
};
try
{
ContentstackResponse response = await client.Stack("<API_KEY>").Release("<RELEASE_UID>").Item().CreateMultipleAsync(items);
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}");
}All parameters: named arguments and a branch key in the response
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient();
List<ReleaseItemModel> items = new List<ReleaseItemModel>
{
new ReleaseItemModel { Uid = "<ENTRY_UID>", ContentTypeUID = "<CONTENT_TYPE_UID>", Version = 3, Locale = "fr-fr", Action = "unpublish" }
};
ParameterCollection collection = new ParameterCollection();
collection.Add("include_branch", true);
try
{
ContentstackResponse response = await client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>").Release("<RELEASE_UID>").Item().CreateMultipleAsync(model: items, collection: collection);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}Delete
Delete removes the entries and assets you list from the release that the ReleaseItem object belongs to.
| Name | Type | Description |
|---|---|---|
| models (required) | List<ReleaseItemModel> | The entries and assets to remove. |
| collection | ParameterCollection? | Adds query parameters, for example all. |
Returns: ContentstackResponse. The API response for the removed items.
Validation
- Throws ArgumentNullException (parameter model) if models is null, before any request.
- The SDK does not check the list or its items. An item that is not in the release reaches the API, and the SDK throws the rejection as ContentstackErrorException.
- collection set to null sends no query parameters.
- Throws ContentstackErrorException when the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Sends one DELETE request to /releases/<RELEASE_UID>/items with the body {"items": [...]} and a Content-Type: application/json header, and the entries of collection as query parameters. See Remove an item from a Release in the Content Management API reference.
- Each item in the body holds every ReleaseItemModel property that is not null. Match the UID, version, locale, content type UID, and action of the item in the release.
- The API reference documents an all query parameter in Delete multiple items from a Release. Add all set to true to collection to remove every item of the release at once.
- Returns the raw API response.
Warning The SDK and the API offer no undo for this request. To put an item back, add it again with the CreateMultiple method.
Example
Basic usage: remove one entry from a release
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
List<ReleaseItemModel> models = new List<ReleaseItemModel>
{
new ReleaseItemModel { Uid = "<ENTRY_UID>", ContentTypeUID = "<CONTENT_TYPE_UID>", Version = 2, Locale = "en-us", Action = "publish" }
};
try
{
ContentstackResponse response = client.Stack("<API_KEY>").Release("<RELEASE_UID>").Item().Delete(models);
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}");
}All parameters: remove every item of a release
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient();
ParameterCollection collection = new ParameterCollection();
collection.Add("all", true);
try
{
// The SDK needs a list even when "all" selects every item.
ContentstackResponse response = client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>").Release("<RELEASE_UID>").Item().Delete(new List<ReleaseItemModel>(), collection);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}DeleteAsync
DeleteAsync removes the entries and assets you list from the release that the ReleaseItem object belongs to, without blocking the calling thread.
| Name | Type | Description |
|---|---|---|
| models (required) | List<ReleaseItemModel> | The entries and assets to remove. |
| collection | ParameterCollection? | Adds query parameters, for example all. |
Returns: Task<ContentstackResponse>. The API response for the removed items.
Validation
- Throws ArgumentNullException (parameter model) if models is null. The SDK throws it when you call DeleteAsync, before it returns a task.
- collection set to null sends no query parameters.
- Throws ContentstackErrorException when the API rejects the request. The exception surfaces when you await the task.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Sends the same DELETE request as Delete and completes the task when the API responds.
- Otherwise behaves like Delete.
Warning The SDK and the API offer no undo for this request. To put an item back, add it again with the CreateMultipleAsync method.
Example
Basic usage: remove one entry from a release
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
List<ReleaseItemModel> models = new List<ReleaseItemModel>
{
new ReleaseItemModel { Uid = "<ENTRY_UID>", ContentTypeUID = "<CONTENT_TYPE_UID>", Version = 2, Locale = "en-us", Action = "publish" }
};
try
{
ContentstackResponse response = await client.Stack("<API_KEY>").Release("<RELEASE_UID>").Item().DeleteAsync(models);
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}");
}All parameters: remove every item of a release
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient();
ParameterCollection collection = new ParameterCollection();
collection.Add("all", true);
try
{
ContentstackResponse response = await client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>").Release("<RELEASE_UID>").Item().DeleteAsync(new List<ReleaseItemModel>(), collection);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}GetAll
GetAll lists the entries and assets in the release that the ReleaseItem object belongs to.
| Name | Type | Description |
|---|---|---|
| parameters | ParameterCollection? | Adds query parameters, for example include_branch. |
Returns: ContentstackResponse. The API response with the items of the release.
Validation
- parameters set to null sends no query parameters.
- Throws ContentstackErrorException when the API rejects the request, for example a release UID that names no release.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Sends one GET request to /releases/<RELEASE_UID>/items, with the entries of parameters as query parameters. See Get all items in a Release in the Content Management API reference.
- The API reference lists one query parameter for the request: include_branch set to true adds the _branch key to the response.
- Returns the raw API response.
Example
Basic usage: list the items of a release
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = client.Stack("<API_KEY>").Release("<RELEASE_UID>").Item().GetAll();
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}");
}All parameters: include the branch key
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient();
ParameterCollection parameters = new ParameterCollection();
parameters.Add("include_branch", true);
try
{
ContentstackResponse response = client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>").Release("<RELEASE_UID>").Item().GetAll(parameters);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}GetAllAsync
GetAllAsync lists the entries and assets in the release that the ReleaseItem object belongs to, without blocking the calling thread.
| Name | Type | Description |
|---|---|---|
| parameters | ParameterCollection? | Adds query parameters, for example include_branch. |
Returns: Task<ContentstackResponse>. The API response with the items of the release.
Validation
- parameters set to null sends no query parameters.
- Throws ContentstackErrorException when the API rejects the request. The exception surfaces when you await the task.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Sends the same GET request as GetAll and completes the task when the API responds.
- Otherwise behaves like GetAll.
Example
Basic usage: list the items of a release
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = await client.Stack("<API_KEY>").Release("<RELEASE_UID>").Item().GetAllAsync();
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}");
}All parameters: include the branch key
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient();
ParameterCollection parameters = new ParameterCollection();
parameters.Add("include_branch", true);
try
{
ContentstackResponse response = await client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>").Release("<RELEASE_UID>").Item().GetAllAsync(parameters);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}UpdateReleaseItem
UpdateReleaseItem moves every entry and asset in the release that the ReleaseItem object belongs to onto its latest version, before you deploy the release.
| Name | Type | Description |
|---|---|---|
| items (required) | List<string> | The items to update. Pass a list that holds only "$all". |
Returns: ContentstackResponse. The API response for the version update.
Validation
- Throws ArgumentNullException (parameter dataModel) if items is null, before any request.
- The SDK does not check the list. The Content Management API reference documents only "$all" for this request, so a list of item UIDs reaches the API unchanged.
- Throws ContentstackErrorException when the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Sends one PUT request to /releases/<RELEASE_UID>/update_items with the body {"items": [...]}. See Update Release items to their latest versions in the API reference.
- Takes no query parameter collection.
- The API reference documents the request as an update of all items at once, with no way to name one item.
- Returns the raw API response.
Example
Basic usage: update every item to its latest version
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = client.Stack("<API_KEY>").Release("<RELEASE_UID>").Item().UpdateReleaseItem(new List<string> { "$all" });
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}");
}Management token: update items before a deployment
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient();
Release release = client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>").Release("<RELEASE_UID>");
try
{
release.Item().UpdateReleaseItem(new List<string> { "$all" });
DeployModel deploy = new DeployModel
{
Environments = new List<string> { "<ENVIRONMENT_NAME>" },
Locales = new List<string> { "en-us" },
Action = "publish"
};
release.Deploy(deploy);
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}UpdateReleaseItemAsync
UpdateReleaseItemAsync moves every entry and asset in the release that the ReleaseItem object belongs to onto its latest version, without blocking the calling thread.
| Name | Type | Description |
|---|---|---|
| items (required) | List<string> | The items to update. Pass a list that holds only "$all". |
Returns: Task<ContentstackResponse>. The API response for the version update.
Validation
- Throws ArgumentNullException (parameter dataModel) if items is null. The SDK throws it when you call UpdateReleaseItemAsync, before it returns a task.
- Throws ContentstackErrorException when the API rejects the request. The exception surfaces when you await the task.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Sends the same PUT request as UpdateReleaseItem and completes the task when the API responds.
- Otherwise behaves like UpdateReleaseItem.
Example
Basic usage: update every item to its latest version
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = await client.Stack("<API_KEY>").Release("<RELEASE_UID>").Item().UpdateReleaseItemAsync(new List<string> { "$all" });
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}");
}Management token: update items, then deploy
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient();
Release release = client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>").Release("<RELEASE_UID>");
try
{
await release.Item().UpdateReleaseItemAsync(new List<string> { "$all" });
DeployModel deploy = new DeployModel
{
Environments = new List<string> { "<ENVIRONMENT_NAME>" },
Locales = new List<string> { "en-us" },
Action = "publish"
};
await release.DeployAsync(deploy);
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}