the Sitecore ItemService API returns a field ÌtemUrl which contains something like this ~/link.aspx?_id=35D02976C748402A8E6F22A2827F4451&_z=z

Is it possible to turn this into a URL like www.mypage.com/hello using the ItemService API? I've tried calling <server>/link.aspx?_id.... but it returns a 404.

Do I have to use the EntityServices API?

I'm using Sitecore 9.1.1

1 Answer 1


It is not possible out of the box in Sitecore.

Filling of item properties is not configurable, it is hardcoded:

private static void FillProperties(ItemDataModel itemModel, Item item, string urlPrefix)
    itemModel.Id = item.ID.Guid.ToString();
    itemModel.Name = item.Name;
    itemModel.Path = item.Paths?.Path;
    itemModel.Language = item.Language?.Name;
    itemModel.Version = ((item.Version != null) ? item.Version.Number : (-1));
    itemModel.IsLatestVersion = (item.Versions?.IsLatestVersion() ?? false);
    itemModel.ParentId = ((!ID.IsNullOrEmpty(item.ParentID)) ? item.ParentID.Guid : Guid.Empty);
    itemModel.TemplateId = ((!ID.IsNullOrEmpty(item.TemplateID)) ? item.TemplateID.Guid : Guid.Empty);
    itemModel.TemplateName = item.TemplateName;
    itemModel.Created = (((DateTimeOffset?)item.Statistics?.Created) ?? default(DateTimeOffset));
    itemModel.Updated = (((DateTimeOffset?)item.Statistics?.Updated) ?? default(DateTimeOffset));
    itemModel.Url = FormattableString.Invariant($"{urlPrefix}('{itemModel.Id}')");
    itemModel.DisplayName = item[FieldIDs.DisplayName];

What you can do:

  1. Inherit your new model data factory from ItemDataModelFactory
  2. Override public virtual ItemDataModel GetModel(Item item, string urlPrefix) method. It calls FillProperties. After filling properties, you should be able either add a new property for the link or change existing.
  3. Inherit from Sitecore.Content.Services.Controllers.ItemsController (it is responsible for ItemService APi). Pass to constructor your new ItemDataModelFactory instead of Sitecore.Content.Services.Items.OData.ItemDataModelFactory
  4. Register your new route
  • 1
    I went with using the EntityService to solve my problem. Thank you for your suggestion! It definitely helped me.
    – Flo
    Commented Mar 30, 2021 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.