1

In Kentico Cloud I got an Item which contains a list of linked items. However this list should be edited from outside with the Kentico Cloud Management API. Is there a way to simply add an Item to this list without updating the whole list?

I am working with the Kentico Cloud SDK in C# and what I have tried so far is upserting a language variant with a new Array of ContentItemIdentifier.byId but whenever I call this it overwrites my already existing list.

private async Task AddOrderToDay(string orderItemExternalId, Guid dayId)
{
    ContentItemVariantIdentifier ident = new ContentItemVariantIdentifier(
        ContentItemIdentifier.ById(dayId),
        LanguageIdentifier.DEFAULT_LANGUAGE);

    UpdateOrdersDay update = new UpdateOrdersDay
    {
        Orders = 
           new[]{ContentItemIdentifier.ByExternalId(orderItemExternalId)}
    };

    ContentItemVariantModel<UpdateOrdersDay> response =
        await this._cmclient.UpsertContentItemVariantAsync(ident, update);
}

What I'd expect is that my new element is added to the existing list of elements in Cloud.

At the moment it simply overwrites them. I tried a workaround: I call the delivery Api to receive the current Items and add them to new new [] {old1, old2, new ItemIdentifier}. However this solution is not very performant.

rocky
  • 7,506
  • 3
  • 33
  • 48
dgref1994
  • 11
  • 1

1 Answers1

0

Currently, the CM API (including v2) does not support adding / removing of linked items one by one.

What you are currently doing is the most efficient way as you get items from Delivery API rather than CM API.

This might change in the future, but for now you have to make that additional request before saving the item.

Enn
  • 2,137
  • 15
  • 24