Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
### Version: 2.26.0
#### Date: Feb-10-2026

##### Feat:
- CDA / DAM 2.0 – AssetFields support
- Added `AssetFields(params string[] fields)` to request specific asset-related metadata via the CDA `asset_fields[]` query parameter
- Implemented on: Entry (single entry fetch), Query (entries find), Asset (single asset fetch), AssetLibrary (assets find)
- Valid parameters: `user_defined_fields`, `embedded_metadata`, `ai_generated_metadata`, `visual_markups`
- Method is chainable; when called with no arguments, the query parameter is not set

### Version: 2.25.2
#### Date: Nov-13-2025

Expand Down
184 changes: 183 additions & 1 deletion Contentstack.Core.Tests/AssetTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Xunit;
using Contentstack.Core.Models;
using System.Threading.Tasks;
Expand Down Expand Up @@ -951,5 +951,187 @@ public void Where_WithSpecialCharacters_ShouldHandleCorrectly_Test()
Assert.NotNull(result);
Assert.IsType<AssetLibrary>(result);
}

[Fact]
public async Task AssetFields_SingleAsset_RequestSucceeds()
{
string uid = await FetchAssetUID();
Asset asset = client.Asset(uid);

asset.AssetFields("user_defined_fields", "embedded_metadata", "ai_generated_metadata", "visual_markups");
Asset result = await asset.Fetch();

if (result == null)
Assert.Fail("Asset.Fetch with AssetFields did not return a result.");
Assert.NotNull(result.Uid);
Assert.NotEmpty(result.FileName);
}

[Fact]
public async Task AssetFields_AssetLibrary_RequestSucceeds()
{
AssetLibrary assetLibrary = client.AssetLibrary();
assetLibrary.AssetFields("user_defined_fields", "ai_generated_metadata");
ContentstackCollection<Asset> assets = await assetLibrary.FetchAll();

if (assets == null)
Assert.Fail("AssetLibrary.FetchAll with AssetFields did not return a result.");
Assert.NotNull(assets.Items);
}

[Fact]
public async Task AssetFields_ChainedWithIncludeMetadata_RequestSucceeds()
{
string uid = await FetchAssetUID();
Asset result = await client.Asset(uid)
.AssetFields("user_defined_fields")
.IncludeMetadata()
.Fetch();

if (result == null)
Assert.Fail("Asset.Fetch with AssetFields and IncludeMetadata did not return a result.");
Assert.NotNull(result.Uid);
Assert.NotEmpty(result.FileName);
}

[Fact]
public async Task AssetFields_AssetLibrary_ChainedWithIncludeMetadata_RequestSucceeds()
{
ContentstackCollection<Asset> assets = await client.AssetLibrary()
.AssetFields("user_defined_fields")
.IncludeMetadata()
.FetchAll();

if (assets == null)
Assert.Fail("AssetLibrary.FetchAll with AssetFields and IncludeMetadata did not return a result.");
Assert.NotNull(assets.Items);
}

[Fact]
public async Task AssetFields_SingleField_RequestSucceeds()
{
string uid = await FetchAssetUID();
Asset asset = client.Asset(uid);
asset.AssetFields("user_defined_fields");
Asset result = await asset.Fetch();

if (result == null)
Assert.Fail("Asset.Fetch with AssetFields single field did not return a result.");
Assert.NotNull(result.Uid);
Assert.NotEmpty(result.FileName);
}

[Fact]
public async Task AssetFields_WithMultipleFields_RequestSucceeds()
{
string uid = await FetchAssetUID();
Asset asset = client.Asset(uid);
asset.AssetFields("user_defined_fields", "embedded_metadata", "visual_markups");
Asset result = await asset.Fetch();

if (result == null)
Assert.Fail("Asset.Fetch with AssetFields multiple fields did not return a result.");
Assert.NotNull(result.Uid);
Assert.NotEmpty(result.FileName);
}

[Fact]
public async Task AssetFields_AssetLibrary_SingleField_RequestSucceeds()
{
AssetLibrary assetLibrary = client.AssetLibrary();
assetLibrary.AssetFields("user_defined_fields");
ContentstackCollection<Asset> assets = await assetLibrary.FetchAll();

if (assets == null)
Assert.Fail("AssetLibrary.FetchAll with AssetFields single field did not return a result.");
Assert.NotNull(assets.Items);
}

[Fact]
public async Task AssetFields_AssetLibrary_WithMultipleFields_RequestSucceeds()
{
AssetLibrary assetLibrary = client.AssetLibrary();
assetLibrary.AssetFields("user_defined_fields", "embedded_metadata", "ai_generated_metadata", "visual_markups");
ContentstackCollection<Asset> assets = await assetLibrary.FetchAll();

if (assets == null)
Assert.Fail("AssetLibrary.FetchAll with AssetFields multiple fields did not return a result.");
Assert.NotNull(assets.Items);
}

[Fact]
public async Task AssetFields_WithNoArguments_RequestSucceeds()
{
string uid = await FetchAssetUID();
Asset asset = client.Asset(uid);
asset.AssetFields();
Asset result = await asset.Fetch();

if (result == null)
Assert.Fail("Asset.Fetch with AssetFields() no arguments did not return a result.");
Assert.NotNull(result.Uid);
}

[Fact]
public async Task AssetFields_AssetLibrary_WithNoArguments_RequestSucceeds()
{
AssetLibrary assetLibrary = client.AssetLibrary();
assetLibrary.AssetFields();
ContentstackCollection<Asset> assets = await assetLibrary.FetchAll();

if (assets == null)
Assert.Fail("AssetLibrary.FetchAll with AssetFields() no arguments did not return a result.");
Assert.NotNull(assets.Items);
}

[Fact]
public async Task AssetFields_WithNull_RequestSucceeds()
{
string uid = await FetchAssetUID();
Asset asset = client.Asset(uid);
asset.AssetFields(null);
Asset result = await asset.Fetch();

if (result == null)
Assert.Fail("Asset.Fetch with AssetFields(null) did not return a result.");
Assert.NotNull(result.Uid);
}

[Fact]
public async Task AssetFields_WithEmptyArray_RequestSucceeds()
{
string uid = await FetchAssetUID();
Asset asset = client.Asset(uid);
asset.AssetFields(new string[0]);
Asset result = await asset.Fetch();

if (result == null)
Assert.Fail("Asset.Fetch with AssetFields(empty array) did not return a result.");
Assert.NotNull(result.Uid);
}

[Fact]
public async Task AssetFields_AssetLibrary_WithNull_RequestSucceeds()
{
AssetLibrary assetLibrary = client.AssetLibrary();
assetLibrary.AssetFields(null);
ContentstackCollection<Asset> assets = await assetLibrary.FetchAll();

if (assets == null)
Assert.Fail("AssetLibrary.FetchAll with AssetFields(null) did not return a result.");
Assert.NotNull(assets.Items);
}

[Fact]
public async Task AssetFields_AssetLibrary_WithEmptyArray_RequestSucceeds()
{
AssetLibrary assetLibrary = client.AssetLibrary();
assetLibrary.AssetFields(new string[0]);
ContentstackCollection<Asset> assets = await assetLibrary.FetchAll();

if (assets == null)
Assert.Fail("AssetLibrary.FetchAll with AssetFields(empty array) did not return a result.");
Assert.NotNull(assets.Items);
}
}
}
1 change: 1 addition & 0 deletions Contentstack.Core.Tests/Contentstack.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<PackageReference Include="AutoFixture" Version="4.18.1" />
<PackageReference Include="AutoFixture.AutoMoq" Version="4.18.1" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
</ItemGroup>

<ItemGroup>
Expand Down
109 changes: 108 additions & 1 deletion Contentstack.Core.Tests/EntryTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Xunit;
using Contentstack.Core.Models;
using System.Threading.Tasks;
Expand Down Expand Up @@ -457,5 +457,112 @@ public async Task GetMetadata()
Assert.True(true, "GetMetadata() returns a valid dictionary (may be empty)");
}
}

[Fact]
public async Task AssetFields_SingleEntry_RequestSucceeds()
{
ContentType contenttype = client.ContentType(source);
string uid = await GetUID("source1");
Entry sourceEntry = contenttype.Entry(uid);

sourceEntry.AssetFields("user_defined_fields", "embedded_metadata", "ai_generated_metadata", "visual_markups");
var result = await sourceEntry.Fetch<Entry>();

if (result == null)
Assert.Fail("Entry.Fetch with AssetFields did not return a result.");
Assert.NotNull(result.Uid);
}

[Fact]
public async Task AssetFields_ChainedWithIncludeMetadata_RequestSucceeds()
{
ContentType contenttype = client.ContentType(source);
string uid = await GetUID("source1");
Entry sourceEntry = contenttype.Entry(uid);

var result = await sourceEntry
.AssetFields("user_defined_fields")
.IncludeMetadata()
.Fetch<Entry>();

if (result == null)
Assert.Fail("Entry.Fetch with AssetFields and IncludeMetadata did not return a result.");
Assert.NotNull(result.Uid);
}

[Fact]
public async Task AssetFields_SingleField_RequestSucceeds()
{
ContentType contenttype = client.ContentType(source);
string uid = await GetUID("source1");
Entry sourceEntry = contenttype.Entry(uid);

sourceEntry.AssetFields("user_defined_fields");
var result = await sourceEntry.Fetch<Entry>();

if (result == null)
Assert.Fail("Entry.Fetch with AssetFields single field did not return a result.");
Assert.NotNull(result.Uid);
}

[Fact]
public async Task AssetFields_WithMultipleFields_RequestSucceeds()
{
ContentType contenttype = client.ContentType(source);
string uid = await GetUID("source1");
Entry sourceEntry = contenttype.Entry(uid);

sourceEntry.AssetFields("user_defined_fields", "embedded_metadata", "visual_markups");
var result = await sourceEntry.Fetch<Entry>();

if (result == null)
Assert.Fail("Entry.Fetch with AssetFields multiple fields did not return a result.");
Assert.NotNull(result.Uid);
}

[Fact]
public async Task AssetFields_WithNoArguments_RequestSucceeds()
{
ContentType contenttype = client.ContentType(source);
string uid = await GetUID("source1");
Entry sourceEntry = contenttype.Entry(uid);

sourceEntry.AssetFields();
var result = await sourceEntry.Fetch<Entry>();

if (result == null)
Assert.Fail("Entry.Fetch with AssetFields() no arguments did not return a result.");
Assert.NotNull(result.Uid);
}

[Fact]
public async Task AssetFields_WithNull_RequestSucceeds()
{
ContentType contenttype = client.ContentType(source);
string uid = await GetUID("source1");
Entry sourceEntry = contenttype.Entry(uid);

sourceEntry.AssetFields(null);
var result = await sourceEntry.Fetch<Entry>();

if (result == null)
Assert.Fail("Entry.Fetch with AssetFields(null) did not return a result.");
Assert.NotNull(result.Uid);
}

[Fact]
public async Task AssetFields_WithEmptyArray_RequestSucceeds()
{
ContentType contenttype = client.ContentType(source);
string uid = await GetUID("source1");
Entry sourceEntry = contenttype.Entry(uid);

sourceEntry.AssetFields(new string[0]);
var result = await sourceEntry.Fetch<Entry>();

if (result == null)
Assert.Fail("Entry.Fetch with AssetFields(empty array) did not return a result.");
Assert.NotNull(result.Uid);
}
}
}
Loading
Loading