-
Couldn't load subscription status.
- Fork 31
Open
Description
Brief bug description
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/net
using Kontent.Ai.Management;
var client = new ManagementClient(new ManagementOptions
{
ApiKey = "<YOUR_API_KEY>",
ProjectId = "<YOUR_PROJECT_ID>"
});
var identifier = Reference.ById(Guid.Parse("fcbb12e6-66a3-4672-85d9-d502d16b8d9c"));
// var identifier = Reference.ByCodename("which-brewing-fits-you");
var response = 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
Metadata
Metadata
Assignees
Labels
No labels