Asset
Asset
The Asset class uploads, replaces, fetches, publishes, unpublishes, and deletes the assets of a stack. Assets are the media files of a stack, for example images, videos, and PDFs.
When to Use This Class: Use this class when your code adds files to a stack or publishes them to an environment. It also lists the entries that use a file before you remove it.
Conceptual Role: Acts as the Content Management API (CMA) client for the /assets endpoint. Call stack.Asset() to get an instance. The instance also opens the asset Folder and asset Version classes.
Returns: Asset. A handle for asset operations.
Instance State
The UID you pass to stack.Asset() decides which methods you can call on the instance:
- Call stack.Asset() without a UID to work with the asset collection, for example Query or Create.
- Call stack.Asset("<ASSET_UID>") to work with one asset, for example Fetch or Publish.
If you call a method from the other group, it throws InvalidOperationException before any request leaves the SDK. The Method Index below lists every method in each group.
Warning The SDK treats an empty string as no UID in its checks, so stack.Asset("") allows Query, Create, and Folder. The request path still ends in a slash (/assets/). Pass null, or call stack.Asset() with no argument, when you mean the collection.
Warning Set the asset UID only through stack.Asset("<ASSET_UID>"). The SDK builds the request path when you call stack.Asset(). Setting the Uid property later changes which methods the SDK allows without changing which asset the request targets.
Class-Level Notes
Authentication.
- stack.Asset() throws InvalidOperationException when the client has no authtoken and the Stack has no management token, and when the Stack has no API key.
- Every method except Create and Update repeats the login check when you call it.
- The CMA accepts an authtoken, an Open Authorization (OAuth) token, or a management token for every asset request.
Branch scoping.
- The branchUid argument of client.Stack() adds a branch header to every request from that Stack. The CMA then reads and writes assets in that branch.
Errors.
- 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.
- A method that returns without throwing returns a ContentstackResponse with a success status. Read its body with OpenJsonObjectResponse() or OpenTResponse<T>().
Rate Limiting & Retry.
- This SDK automatically retries a request that returns 429, 500, 502, 503, or 504, with configurable delay and attempt limits.
Additional Resource For more information on retry limits and delay, refer to the ContentstackClientOptions documentation.
Async methods.
- The async methods run the same client-side checks as soon as you call them, before they return a task.
Capability Matrix
| Capability | Supported | Notes / Alternative |
|---|---|---|
| Change the title, description, or tags without uploading a file | No | Update always uploads a file, because AssetModel requires file content. Upload the same file again with the new values. |
| Send query parameters on upload or replace (relative_urls, include_dimension) | No | Create and Update accept a collection argument and do not send it. |
| List the folders of a stack | Through Query | Call Find with include_folders set to true. See the Query method. |
| Generate a permanent asset URL | No | The CMA Generate permanent asset URL request has no method in this SDK. |
| Publish or delete many assets in one request | Yes | Use the BulkOperation class. |
Properties
| Property | Type | Access | Default | Description |
|---|---|---|---|---|
| Uid | string? | get, set | The UID passed to stack.Asset() | UID of the asset. null on a collection instance. |
Method Index
The groups below follow the Instance State split.
Work with the asset collection. Available on stack.Asset() when you pass no UID.
| Method Name | Returns | Description |
|---|---|---|
| Query | A new query for assets. | Builds a query that lists assets. |
| Create | The API response with the uploaded asset. | Uploads a file as a new asset. |
| CreateAsync | The API response with the uploaded asset. | Uploads a file as a new asset asynchronously. |
| Folder | A new folder object. | Opens the asset folders of the stack. |
Manage one asset. Available on stack.Asset("<ASSET_UID>").
| Method Name | Returns | Description |
|---|---|---|
| Fetch | The API response with the requested asset. | Retrieves one asset. |
| FetchAsync | The API response with the requested asset. | Retrieves one asset asynchronously. |
| Update | The API response with the replaced asset. | Replaces the file of an asset. |
| UpdateAsync | The API response with the replaced asset. | Replaces the file of an asset asynchronously. |
| Delete | The API response with the deletion notice. | Deletes an asset. |
| DeleteAsync | The API response with the deletion notice. | Deletes an asset asynchronously. |
| References | The API response with the entries and content types that reference the asset. | Lists where the asset is used. |
| ReferencesAsync | The API response with the entries and content types that reference the asset. | Lists where the asset is used asynchronously. |
| Version | A new version object. | Opens the versions of the asset. |
Publish one asset. Available on stack.Asset("<ASSET_UID>").
| Method Name | Returns | Description |
|---|---|---|
| Publish | The API response with the publish notice. | Publishes an asset to environments. |
| PublishAsync | The API response with the publish notice. | Publishes an asset to environments asynchronously. |
| Unpublish | The API response with the unpublish notice. | Unpublishes an asset from environments. |
| UnpublishAsync | The API response with the unpublish notice. | Unpublishes an asset from environments asynchronously. |
Class-Level Snippet
The snippet below uploads an image into a folder, publishes it to one environment, and lists the entries that use it.
using System;
using System.Collections.Generic;
using System.Text.Json.Nodes;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
Stack stack = client.Stack("<API_KEY>");
try
{
AssetModel model = new AssetModel("banner.png", "<FILE_PATH>", "image/png", title: "Home Banner", parentUID: "<FOLDER_UID>");
ContentstackResponse created = await stack.Asset().CreateAsync(model);
string assetUid = created.OpenJsonObjectResponse()["asset"]?["uid"]?.ToString() ?? "";
PublishUnpublishDetails details = new PublishUnpublishDetails()
{
Environments = new List<string> { "<ENVIRONMENT_NAME>" },
Locales = new List<string> { "<LOCALE_CODE>" }
};
await stack.Asset(assetUid).PublishAsync(details);
JsonObject references = (await stack.Asset(assetUid).ReferencesAsync()).OpenJsonObjectResponse();
Console.WriteLine(references.ToJsonString());
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}Methods
Each method of the Asset class has its own section below, with its parameters, validation rules, behavior, and examples.
Create
Create uploads a file to the stack as a new asset.
| Name | Type | Description |
|---|---|---|
| model (required) | AssetModel | Holds the file and the asset details to upload. |
| collection | ParameterCollection? | Accepted, but the SDK does not send it. |
Returns: ContentstackResponse. The API response with the uploaded asset.
Validation
- Throws InvalidOperationException if the instance has a UID, because Create adds an asset to the collection. Call stack.Asset() with no argument.
- Throws ArgumentNullException if model is null, because the file in the model is the request body.
- The AssetModel constructor checks the file name and content, so a model with no file cannot reach Create.
- 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 /assets as multipart/form-data, the Upload asset request.
- Builds the form from the model with the fields below. The SDK leaves out a field whose property is null.
- asset[upload]: the file, under FileName, with ContentType as its media type.
- asset[title], asset[description], asset[parent_uid], and asset[tags] from Title, Description, ParentUID, and Tags.
- Does not send collection. The Upload asset request takes the relative_urls, include_dimension, and include_branch query parameters, and Create cannot pass them.
- Returns the raw API response. The new asset sits under the asset key, with its UID in asset.uid.
Example
Basic usage: upload a file from disk
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
AssetModel model = new AssetModel("banner.png", "<FILE_PATH>", "image/png");
ContentstackResponse response = client.Stack("<API_KEY>").Asset().Create(model);
Console.WriteLine(response.OpenJsonObjectResponse()["asset"]?["uid"]);
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: upload into a folder with a title, description, and tags
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("<AUTHTOKEN>");
AssetModel model = new AssetModel(
"banner.png",
"<FILE_PATH>",
"image/png",
title: "Home Banner",
description: "Hero image for the home page",
parentUID: "<FOLDER_UID>",
tags: "banner");
// The SDK does not send this collection with the request.
ParameterCollection collection = new ParameterCollection();
collection.Add("include_dimension", true);
try
{
ContentstackResponse response = client.Stack("<API_KEY>").Asset().Create(model, collection);
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}Upload bytes from memory with a management token
using System;
using System.Text;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient();
byte[] bytes = Encoding.UTF8.GetBytes("{\"campaign\": \"spring\"}");
AssetModel model = new AssetModel("campaign.json", bytes, "application/json", title: "Campaign Settings");
try
{
ContentstackResponse response = client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>").Asset().Create(model);
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}CreateAsync
CreateAsync uploads a file to the stack as a new asset, without blocking the calling thread.
| Name | Type | Description |
|---|---|---|
| model (required) | AssetModel | Holds the file and the asset details to upload. |
| collection | ParameterCollection? | Accepted, but the SDK does not send it. |
Returns: Task<ContentstackResponse>. The API response with the uploaded asset.
Validation
- Throws InvalidOperationException if the instance has a UID, because CreateAsync adds an asset to the collection. Call stack.Asset() with no argument.
- Throws ArgumentNullException if model is null, because the file in the model is the request body.
- The SDK throws the exceptions above when you call CreateAsync, before it returns a task.
- Throws ContentstackErrorException when you await the task and the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Runs the login check that Create skips.
- Otherwise behaves like Create.
Example
Basic usage: upload a file from disk
using System;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
AssetModel model = new AssetModel("banner.png", "<FILE_PATH>", "image/png");
ContentstackResponse response = await client.Stack("<API_KEY>").Asset().CreateAsync(model);
Console.WriteLine(response.OpenJsonObjectResponse()["asset"]?["uid"]);
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: upload a stream into a folder
using System;
using System.IO;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
using FileStream stream = File.OpenRead("<FILE_PATH>");
AssetModel model = new AssetModel(
"brochure.pdf",
stream,
"application/pdf",
title: "Product Brochure",
description: "Brochure for the spring range",
parentUID: "<FOLDER_UID>",
tags: "brochure");
// The SDK does not send this collection with the request.
ParameterCollection collection = new ParameterCollection();
collection.Add("relative_urls", true);
try
{
ContentstackResponse response = await client.Stack("<API_KEY>").Asset().CreateAsync(model, collection);
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}Delete
Delete deletes the asset whose UID you passed to stack.Asset().
This method takes no parameters.
Returns: ContentstackResponse. The API response with the deletion notice.
Validation
- Throws InvalidOperationException if the instance has no UID, because Delete removes one asset. Call stack.Asset("<ASSET_UID>").
- 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 /assets/<ASSET_UID>, the Delete asset request.
- Returns the raw API response.
Example
Warning Delete removes the asset and its file from the stack. Call References first to find the entries that still use the asset.
Basic usage: delete an asset
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = client.Stack("<API_KEY>").Asset("<ASSET_UID>").Delete();
Console.WriteLine(response.OpenJsonObjectResponse()["notice"]);
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}Delete an asset only when no entry references it
using System;
using System.Text.Json.Nodes;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient();
Stack stack = client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>");
try
{
JsonObject references = stack.Asset("<ASSET_UID>").References().OpenJsonObjectResponse();
Console.WriteLine(references.ToJsonString());
// Review the references above, then delete the asset.
stack.Asset("<ASSET_UID>").Delete();
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}DeleteAsync
DeleteAsync deletes the asset whose UID you passed to stack.Asset(), without blocking the calling thread.
This method takes no parameters.
Returns: Task<ContentstackResponse>. The API response with the deletion notice.
Validation
- Throws InvalidOperationException if the instance has no UID, because DeleteAsync removes one asset. Call stack.Asset("<ASSET_UID>").
- The SDK throws the exception above when you call DeleteAsync, before it returns a task.
- Throws ContentstackErrorException when you await the task and the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Behaves like Delete.
Example
Warning DeleteAsync removes the asset and its file from the stack. Call ReferencesAsync first to find the entries that still use the asset.
Basic usage: delete an asset
using System;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = await client.Stack("<API_KEY>").Asset("<ASSET_UID>").DeleteAsync();
Console.WriteLine(response.OpenJsonObjectResponse()["notice"]);
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}Delete several assets one after another
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
Stack stack = client.Stack("<API_KEY>");
List<string> assetUids = new List<string> { "<ASSET_UID>", "<SECOND_ASSET_UID>" };
foreach (string assetUid in assetUids)
{
try
{
await stack.Asset(assetUid).DeleteAsync();
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}
}Fetch
Fetch retrieves the details of the asset whose UID you passed to stack.Asset().
| Name | Type | Description |
|---|---|---|
| collection | ParameterCollection? | Adds query parameters to the request. |
Returns: ContentstackResponse. The API response with the requested asset.
Validation
- Throws InvalidOperationException if the instance has no UID, because Fetch reads one asset. Call stack.Asset("<ASSET_UID>").
- The SDK does not check the UID format. A UID that names no asset reaches the API and fails there.
- collection set to null or left empty 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 GET request to /assets/<ASSET_UID>, the Get an asset request.
- Sends each entry of collection as a query parameter. The Content Management API (CMA) reference lists these parameters for the request, for example:
- version returns that version of the asset. Without it, the API returns the latest version.
- include_path set to true adds the names and UIDs of the parent folders.
- environment, include_publish_details, relative_urls, and include_branch.
- Returns the raw API response. The asset sits under the asset key.
Example
Basic usage: fetch an asset by UID
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = client.Stack("<API_KEY>").Asset("<ASSET_UID>").Fetch();
Console.WriteLine(response.OpenJsonObjectResponse()["asset"]?["title"]);
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: fetch version 2 with its folder path and publish details
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient();
ParameterCollection collection = new ParameterCollection();
collection.Add("version", 2);
collection.Add("include_path", true);
collection.Add("include_publish_details", true);
try
{
ContentstackResponse response = client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>").Asset("<ASSET_UID>").Fetch(collection);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}FetchAsync
FetchAsync retrieves the details of the asset whose UID you passed to stack.Asset(), without blocking the calling thread.
| Name | Type | Description |
|---|---|---|
| collection | ParameterCollection? | Adds query parameters to the request. |
Returns: Task<ContentstackResponse>. The API response with the requested asset.
Validation
- Throws InvalidOperationException if the instance has no UID, because FetchAsync reads one asset. Call stack.Asset("<ASSET_UID>").
- The SDK throws the exception above when you call FetchAsync, before it returns a task.
- Throws ContentstackErrorException when you await the task and the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Behaves like Fetch.
Example
Basic usage: fetch an asset by UID
using System;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = await client.Stack("<API_KEY>").Asset("<ASSET_UID>").FetchAsync();
Console.WriteLine(response.OpenJsonObjectResponse()["asset"]?["title"]);
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: fetch the asset published to an environment
using System;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
ParameterCollection collection = new ParameterCollection();
collection.Add("environment", "<ENVIRONMENT_NAME>");
collection.Add("relative_urls", true);
try
{
ContentstackResponse response = await client.Stack("<API_KEY>").Asset("<ASSET_UID>").FetchAsync(collection);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}Folder
Folder returns a Folder instance that creates, fetches, renames, and deletes the asset folders of the stack.
| Name | Type | Description |
|---|---|---|
| uid | string? | Selects one folder. Omit it to create a folder. |
Returns: Folder. A new folder object.
Validation
- Throws InvalidOperationException if the Asset instance has a UID, because folders belong to the stack, not to one asset. Call stack.Asset().Folder().
- The SDK does not check uid. A UID that names no folder reaches the API on the next call and fails there.
Behavior
- Sends no request. The request happens when you call a method on the returned instance.
- Without uid, the instance allows Create. With uid, it allows Fetch, Update, and Delete. The Folder class page lists the methods in each group.
Example
Basic usage: create an asset folder
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
Folder folder = client.Stack("<API_KEY>").Asset().Folder();
ContentstackResponse response = folder.Create("Product Images");
Console.WriteLine(response.OpenJsonObjectResponse()["asset"]?["uid"]);
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: fetch one asset folder by UID
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
Folder folder = client.Stack("<API_KEY>").Asset().Folder("<FOLDER_UID>");
ContentstackResponse response = folder.Fetch();
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}Edge case: call Folder on an asset that has a UID
using System;
using Contentstack.Management.Core;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
client.Stack("<API_KEY>").Asset("<ASSET_UID>").Folder();
}
catch (InvalidOperationException e)
{
// Thrown because Folder needs the asset collection, stack.Asset() with no UID
Console.WriteLine(e.Message);
}Publish
Publish publishes the asset whose UID you passed to stack.Asset() to one or more environments, now or at a scheduled time.
| Name | Type | Description |
|---|---|---|
| details (required) | PublishUnpublishDetails | Sets the environments, locales, version, and schedule. |
| apiVersion | string? | Sends this value in the api_version header. |
Returns: ContentstackResponse. The API response with the publish notice.
Validation
- Throws InvalidOperationException if the instance has no UID, because Publish acts on one asset. Call stack.Asset("<ASSET_UID>").
- Throws ArgumentNullException if details is null, because the details are the request body.
- The SDK does not check the environment names, locale codes, or the ScheduledAt format. Invalid values reach the API and fail there.
- 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 /assets/<ASSET_UID>/publish, the Publish an asset request.
- Builds the request body from PublishUnpublishDetails and leaves out every property that is null or an empty list:
- asset.environments from Environments and asset.locales from Locales.
- version from Version.
- scheduled_at from ScheduledAt. The API publishes the asset at that time. The Content Management API (CMA) reference takes an ISO 8601 date and time, for example 2026-12-01T09:00:00.000Z.
- asset.variants and asset.variant_rules from Variants and VariantRules. These are entry variant settings, and the CMA reference for this request does not list them.
- Sends apiVersion as the api_version header only when it is not null or empty. The CMA reference for this request lists no api_version header.
- Returns the raw API response.
Example
Basic usage: publish an asset to one environment
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>");
PublishUnpublishDetails details = new PublishUnpublishDetails()
{
Environments = new List<string> { "<ENVIRONMENT_NAME>" },
Locales = new List<string> { "<LOCALE_CODE>" }
};
try
{
ContentstackResponse response = client.Stack("<API_KEY>").Asset("<ASSET_UID>").Publish(details);
Console.WriteLine(response.OpenJsonObjectResponse()["notice"]);
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: schedule a publish of version 3 with an API version header
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient();
PublishUnpublishDetails details = new PublishUnpublishDetails()
{
Environments = new List<string> { "<ENVIRONMENT_NAME>" },
Locales = new List<string> { "<LOCALE_CODE>" },
Version = 3,
ScheduledAt = "2026-12-01T09:00:00.000Z"
};
try
{
ContentstackResponse response = client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.Asset("<ASSET_UID>")
.Publish(details, apiVersion: "3.2");
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}PublishAsync
PublishAsync publishes the asset whose UID you passed to stack.Asset() to one or more environments, without blocking the calling thread.
| Name | Type | Description |
|---|---|---|
| details (required) | PublishUnpublishDetails | Sets the environments, locales, version, and schedule. |
| apiVersion | string? | Sends this value in the api_version header. |
Returns: Task<ContentstackResponse>. The API response with the publish notice.
Validation
- Throws InvalidOperationException if the instance has no UID, because PublishAsync acts on one asset. Call stack.Asset("<ASSET_UID>").
- Throws ArgumentNullException if details is null, because the details are the request body.
- The SDK throws the exceptions above when you call PublishAsync, before it returns a task.
- Throws ContentstackErrorException when you await the task and the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Behaves like Publish.
Example
Basic usage: publish an asset to one environment
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
PublishUnpublishDetails details = new PublishUnpublishDetails()
{
Environments = new List<string> { "<ENVIRONMENT_NAME>" },
Locales = new List<string> { "<LOCALE_CODE>" }
};
try
{
ContentstackResponse response = await client.Stack("<API_KEY>").Asset("<ASSET_UID>").PublishAsync(details);
Console.WriteLine(response.OpenJsonObjectResponse()["notice"]);
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: schedule a publish of version 3 with an API version header
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient();
PublishUnpublishDetails details = new PublishUnpublishDetails()
{
Environments = new List<string> { "<ENVIRONMENT_NAME>" },
Locales = new List<string> { "<LOCALE_CODE>" },
Version = 3,
ScheduledAt = "2026-12-01T09:00:00.000Z"
};
try
{
ContentstackResponse response = await client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.Asset("<ASSET_UID>")
.PublishAsync(details, apiVersion: "3.2");
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}Query
Query builds a query that lists the assets of the stack.
This method takes no parameters.
Returns: Query. A new query for assets.
Validation
- Throws InvalidOperationException if the instance has a UID, because Query lists the asset collection. Call stack.Asset() with no argument.
- Query sends no request. Errors from the API come from the Find or FindAsync call that follows, not from Query.
Behavior
- Sends no request. Find and FindAsync send one GET request to /assets, the Get all assets request.
- Chain Limit, Skip, and IncludeCount on the query to page through the results. The SDK requests one page per Find call. When you set no limit, the API applies its own page size.
- Pass other query parameters of the Get all assets request in the ParameterCollection argument of Find. The Content Management API (CMA) reference lists these parameters, for example:
- folder set to a folder UID returns the assets of that folder. cs_root returns the assets of the root folder.
- include_folders set to true adds the asset folders to the response.
- environment, include_publish_details, relative_urls, asc, desc, and include_branch.
- query set through ParameterCollection.AddQuery filters the assets. A query of {"is_dir": true, "name": "<FOLDER_NAME>"} returns the folder with that name, the CMA Get a single folder by name request.
- Find returns the raw API response.
Example
Basic usage: list the assets of a stack
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = client.Stack("<API_KEY>").Asset().Query().Find();
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}");
}Pagination: read the second page of 20 assets with a total count
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = client.Stack("<API_KEY>").Asset().Query()
.Limit(20)
.Skip(20)
.IncludeCount()
.Find();
Console.WriteLine(response.OpenJsonObjectResponse()["count"]);
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}List the assets and subfolders of one folder
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
ParameterCollection collection = new ParameterCollection();
collection.Add("folder", "<FOLDER_UID>");
collection.Add("include_folders", true);
try
{
ContentstackResponse response = client.Stack("<API_KEY>").Asset().Query().Find(collection);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}Find an asset folder by name
using System;
using System.Text.Json.Nodes;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
ParameterCollection collection = new ParameterCollection();
collection.AddQuery(new JsonObject { ["is_dir"] = true, ["name"] = "Product Images" });
try
{
ContentstackResponse response = await client.Stack("<API_KEY>").Asset().Query().FindAsync(collection);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}References
References lists the entries and content types that reference the asset whose UID you passed to stack.Asset().
| Name | Type | Description |
|---|---|---|
| collection | ParameterCollection? | Adds query parameters to the request. |
Returns: ContentstackResponse. The API response with the entries and content types that reference the asset.
Validation
- Throws InvalidOperationException if the instance has no UID, because References reads the references of one asset. Call stack.Asset("<ASSET_UID>").
- collection set to null or left empty 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 GET request to /assets/<ASSET_UID>/references, the Get asset references request.
- Sends each entry of collection as a query parameter. The Content Management API (CMA) reference lists include_count, include_publish_details, include_branch, and deleted for this request.
- include_publish_details set to true adds the version number, the version name, and the publish details of the asset to the response.
- Returns the raw API response.
Example
Basic usage: list where an asset is used
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = client.Stack("<API_KEY>").Asset("<ASSET_UID>").References();
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 count and publish details
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient();
ParameterCollection collection = new ParameterCollection();
collection.Add("include_count", true);
collection.Add("include_publish_details", true);
try
{
ContentstackResponse response = client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>").Asset("<ASSET_UID>").References(collection);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}ReferencesAsync
ReferencesAsync lists the entries and content types that reference the asset whose UID you passed to stack.Asset(), without blocking the calling thread.
| Name | Type | Description |
|---|---|---|
| collection | ParameterCollection? | Adds query parameters to the request. |
Returns: Task<ContentstackResponse>. The API response with the entries and content types that reference the asset.
Validation
- Throws InvalidOperationException if the instance has no UID, because ReferencesAsync reads the references of one asset. Call stack.Asset("<ASSET_UID>").
- The SDK throws the exception above when you call ReferencesAsync, before it returns a task.
- Throws ContentstackErrorException when you await the task and the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Behaves like References.
Example
Basic usage: list where an asset is used
using System;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = await client.Stack("<API_KEY>").Asset("<ASSET_UID>").ReferencesAsync();
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 count of references
using System;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
ParameterCollection collection = new ParameterCollection();
collection.Add("include_count", true);
try
{
ContentstackResponse response = await client.Stack("<API_KEY>").Asset("<ASSET_UID>").ReferencesAsync(collection);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}Unpublish
Unpublish unpublishes the asset whose UID you passed to stack.Asset() from one or more environments, now or at a scheduled time.
| Name | Type | Description |
|---|---|---|
| details (required) | PublishUnpublishDetails | Sets the environments, locales, version, and schedule. |
| apiVersion | string? | Sends this value in the api_version header. |
Returns: ContentstackResponse. The API response with the unpublish notice.
Validation
- Throws InvalidOperationException if the instance has no UID, because Unpublish acts on one asset. Call stack.Asset("<ASSET_UID>").
- Throws ArgumentNullException if details is null, because the details are the request body.
- The SDK does not check the environment names, locale codes, or the ScheduledAt format. Invalid values reach the API and fail there.
- 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 /assets/<ASSET_UID>/unpublish, the Unpublish an asset request.
- Builds the request body from PublishUnpublishDetails and leaves out every property that is null or an empty list:
- asset.environments from Environments and asset.locales from Locales.
- version from Version.
- scheduled_at from ScheduledAt. The API unpublishes the asset at that time. The Content Management API (CMA) reference takes an ISO 8601 date and time, for example 2026-12-01T09:00:00.000Z.
- asset.variants and asset.variant_rules from Variants and VariantRules. These are entry variant settings, and the CMA reference for this request does not list them.
- Sends apiVersion as the api_version header only when it is not null or empty. The CMA reference for this request lists no api_version header.
- Returns the raw API response.
Example
Warning Unpublish removes the asset from the environments you name. Content delivery requests to those environments stop returning the asset.
Basic usage: unpublish an asset from one environment
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>");
PublishUnpublishDetails details = new PublishUnpublishDetails()
{
Environments = new List<string> { "<ENVIRONMENT_NAME>" },
Locales = new List<string> { "<LOCALE_CODE>" }
};
try
{
ContentstackResponse response = client.Stack("<API_KEY>").Asset("<ASSET_UID>").Unpublish(details);
Console.WriteLine(response.OpenJsonObjectResponse()["notice"]);
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: schedule a unpublish of version 3 with an API version header
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient();
PublishUnpublishDetails details = new PublishUnpublishDetails()
{
Environments = new List<string> { "<ENVIRONMENT_NAME>" },
Locales = new List<string> { "<LOCALE_CODE>" },
Version = 3,
ScheduledAt = "2026-12-01T09:00:00.000Z"
};
try
{
ContentstackResponse response = client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.Asset("<ASSET_UID>")
.Unpublish(details, apiVersion: "3.2");
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}UnpublishAsync
UnpublishAsync unpublishes the asset whose UID you passed to stack.Asset() from one or more environments, without blocking the calling thread.
| Name | Type | Description |
|---|---|---|
| details (required) | PublishUnpublishDetails | Sets the environments, locales, version, and schedule. |
| apiVersion | string? | Sends this value in the api_version header. |
Returns: Task<ContentstackResponse>. The API response with the unpublish notice.
Validation
- Throws InvalidOperationException if the instance has no UID, because UnpublishAsync acts on one asset. Call stack.Asset("<ASSET_UID>").
- Throws ArgumentNullException if details is null, because the details are the request body.
- The SDK throws the exceptions above when you call UnpublishAsync, before it returns a task.
- Throws ContentstackErrorException when you await the task and the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Behaves like Unpublish.
Example
Warning UnpublishAsync removes the asset from the environments you name. Content delivery requests to those environments stop returning the asset.
Basic usage: unpublish an asset from one environment
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
PublishUnpublishDetails details = new PublishUnpublishDetails()
{
Environments = new List<string> { "<ENVIRONMENT_NAME>" },
Locales = new List<string> { "<LOCALE_CODE>" }
};
try
{
ContentstackResponse response = await client.Stack("<API_KEY>").Asset("<ASSET_UID>").UnpublishAsync(details);
Console.WriteLine(response.OpenJsonObjectResponse()["notice"]);
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: schedule a unpublish of version 3 with an API version header
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient();
PublishUnpublishDetails details = new PublishUnpublishDetails()
{
Environments = new List<string> { "<ENVIRONMENT_NAME>" },
Locales = new List<string> { "<LOCALE_CODE>" },
Version = 3,
ScheduledAt = "2026-12-01T09:00:00.000Z"
};
try
{
ContentstackResponse response = await client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.Asset("<ASSET_UID>")
.UnpublishAsync(details, apiVersion: "3.2");
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}Update
Update replaces the file of an existing asset with a new file.
| Name | Type | Description |
|---|---|---|
| model (required) | AssetModel | Holds the new file and the asset details. |
| collection | ParameterCollection? | Accepted, but the SDK does not send it. |
Returns: ContentstackResponse. The API response with the replaced asset.
Validation
- Throws InvalidOperationException if the instance has no UID, because Update replaces one asset. Call stack.Asset("<ASSET_UID>").
- Throws ArgumentNullException if model is null, because the file in the model is the request body.
- 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 /assets/<ASSET_UID> as multipart/form-data, the Replace asset request.
- Builds the same form fields as Create: asset[upload] always, and asset[title], asset[description], asset[parent_uid], and asset[tags] when the model property is not null.
- Does not send collection. The environment and relative_urls query parameters of the Replace asset request do not reach the API.
- Returns the raw API response. The asset sits under the asset key.
Limitations
- Does not change the title, description, or tags of an asset without a file. The Content Management API (CMA) Update asset request does, and this SDK has no method for it. Pass the current file in the model with the new details.
Example
Basic usage: replace the file of an asset
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
AssetModel model = new AssetModel("banner.png", "<FILE_PATH>", "image/png");
ContentstackResponse response = client.Stack("<API_KEY>").Asset("<ASSET_UID>").Update(model);
Console.WriteLine(response.OpenJsonObjectResponse()["asset"]?["url"]);
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: replace the file and move the asset to another folder
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("<AUTHTOKEN>");
AssetModel model = new AssetModel(
"banner.png",
"<FILE_PATH>",
"image/png",
title: "Home Banner (Spring)",
description: "Spring hero image for the home page",
parentUID: "<FOLDER_UID>",
tags: "banner");
// The SDK does not send this collection with the request.
ParameterCollection collection = new ParameterCollection();
collection.Add("relative_urls", true);
try
{
ContentstackResponse response = client.Stack("<API_KEY>", "<MANAGEMENT_TOKEN>").Asset("<ASSET_UID>").Update(model, collection);
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}UpdateAsync
UpdateAsync replaces the file of an existing asset with a new file, without blocking the calling thread.
| Name | Type | Description |
|---|---|---|
| model (required) | AssetModel | Holds the new file and the asset details. |
| collection | ParameterCollection? | Accepted, but the SDK does not send it. |
Returns: Task<ContentstackResponse>. The API response with the replaced asset.
Validation
- Throws InvalidOperationException if the instance has no UID, because UpdateAsync replaces one asset. Call stack.Asset("<ASSET_UID>").
- Throws ArgumentNullException if model is null, because the file in the model is the request body.
- The SDK throws the exceptions above when you call UpdateAsync, before it returns a task.
- Throws ContentstackErrorException when you await the task and the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Runs the login check that Update skips.
- Otherwise behaves like Update.
Example
Basic usage: replace the file of an asset
using System;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
AssetModel model = new AssetModel("banner.png", "<FILE_PATH>", "image/png");
ContentstackResponse response = await client.Stack("<API_KEY>").Asset("<ASSET_UID>").UpdateAsync(model);
Console.WriteLine(response.OpenJsonObjectResponse()["asset"]?["url"]);
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: replace the file with new details
using System;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
AssetModel model = new AssetModel(
"banner.png",
"<FILE_PATH>",
"image/png",
title: "Home Banner (Spring)",
description: "Spring hero image for the home page",
parentUID: "<FOLDER_UID>",
tags: "banner");
// The SDK does not send this collection with the request.
ParameterCollection collection = new ParameterCollection();
collection.Add("relative_urls", true);
try
{
ContentstackResponse response = await client.Stack("<API_KEY>").Asset("<ASSET_UID>").UpdateAsync(model, collection);
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}Version
Version returns a Version instance that lists the versions of the asset and names or unnames one version.
| Name | Type | Description |
|---|---|---|
| versionNumber | int? | Selects one version. Omit it to list all versions. |
Returns: Version. A new version object.
Validation
- Throws InvalidOperationException if the instance has no UID, because versions belong to one asset. Call stack.Asset("<ASSET_UID>").
- The SDK does not check versionNumber. A number that names no version reaches the API on the next call and fails there.
Behavior
- Sends no request. The request happens when you call a method on the returned instance.
- Without versionNumber, call GetAll. It sends the Get Details of All Versions of an Asset request to /assets/<ASSET_UID>/versions.
- With versionNumber, call SetName or Delete. Both act on /assets/<ASSET_UID>/versions/<VERSION_NUMBER>/name.
- Delete on the returned object removes the name of the version, not the version itself. It sends the Delete Version Name of Asset request, which resets the name to the version number.
Example
Basic usage: list every version of an asset
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = client.Stack("<API_KEY>").Asset("<ASSET_UID>").Version().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: name version 2 of an asset
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
Contentstack.Management.Core.Models.Version version = client.Stack("<API_KEY>").Asset("<ASSET_UID>").Version(2);
ContentstackResponse response = version.SetName("Spring campaign");
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}