You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to retrieve an AssetModel (and other items such as LanguageVariantModel), code examples show that a nullable object can be returned ( see Retrieve an asset ). The assumption here is that if no item is found, then a null item is returned according to the code in the C# sample:
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/netusing Kontent.Ai.Management;varclient=new ManagementClient(new ManagementOptions
{ApiKey="<YOUR_API_KEY>",ProjectId="<YOUR_PROJECT_ID>"});varidentifier= Reference.ById(Guid.Parse("fcbb12e6-66a3-4672-85d9-d502d16b8d9c"));// var identifier = Reference.ByCodename("which-brewing-fits-you");varresponse=await client.GetAssetAsync(identifier);
Assert.NotNull(response);
What actually happens is that a ManagementException is thrown:
Unhandled exception. Kontent.Ai.Management.Exceptions.ManagementException: The requested asset '{external id: 035166}' was not found.
at Kontent.Ai.Management.Modules.HttpClient.ManagementHttpClient.SendAsync(IMessageCreator messageCreator, String endpointUrl, HttpMethod method, HttpContent requestContent, Dictionary`2 headers)
at Kontent.Ai.Management.Modules.ActionInvoker.ActionInvoker.InvokeReadOnlyMethodAsync[TResponse](String endpointUrl, HttpMethod method, Dictionary`2 headers)
at Kontent.Ai.Management.ManagementClient.GetAssetAsync(Reference identifier)
Is this intended functionality and does the documentation just need to be updated? It's a frustrating pattern, as integration and content migration needs to have an unusually high number of try-catch block to deal with determining if an item exists.
Test environment
Platform/OS: .NET 6, macOS Ventura 31.5.1
Version: Kontent.ai.Management 4.6.0
The text was updated successfully, but these errors were encountered:
Brief bug description
When trying to retrieve an
AssetModel
(and other items such asLanguageVariantModel
), code examples show that a nullable object can be returned ( see Retrieve an asset ). The assumption here is that if no item is found, then a null item is returned according to the code in the C# sample:What actually happens is that a
ManagementException
is thrown:Is this intended functionality and does the documentation just need to be updated? It's a frustrating pattern, as integration and content migration needs to have an unusually high number of try-catch block to deal with determining if an item exists.
Test environment
The text was updated successfully, but these errors were encountered: