While trying to retrieve Content using dynamic component presentation, the KeywordModelData returns only the ID and other values are missing. For the field "name" as shown below. The same question exists for Java but i need a solution for .Net, is there any alternate model service code available to get complete KeywordModelData. Thanks in advance.

Content":{ "name":{"$type":"KeywordModelData","Id":"1455"}, "title":"Efficiency", "text":{"$type":"RichTextData","Fragments":["Rich Text Data from Comp"]}, "filterType":"CheckBox"}

enter image description here

private EntityModelData CreateEntityModelData(ComponentPresentation componentPresentation, Localization localization)
    {
        EntityModelData entityModelData = SiteConfiguration.ModelServiceProvider.GetEntityModelData(componentPresentation.ComponentId + "-" + componentPresentation.ComponentTemplateId, localization);
        ContentModelData componentContent = entityModelData.Content;
        ContentModelData componentMetadata = entityModelData.Metadata;
        return new EntityModelData
        {
            Id = componentPresentation.ComponentId.ToString(),
            SchemaId = entityModelData.SchemaId.ToString(),
            Metadata = componentMetadata,
            Content = componentContent
        };
    }
  • BTW: you should not use the ModelServiceProvider directly in application code; use the ContentProvider instead (it provides caching and semantic mapping functionality). – Rick Pannekoek Nov 16 at 8:16
up vote 4 down vote accepted

This is a defect in the DXA 2.0 Model Service, which has already been hotfixed. See https://github.com/sdl/dxa-model-service/commit/77c2043ba690ae15f3efee9c3f598cb7bd79a4e8

Contact SDL Customer Support to receive this hotfix.

  • Thanks Rick. The above hotfix is for java and we have a .net application. We have contacted customer service and they will be working on a .net equivalent fix and update us. Thanks for your input. – GJin Nov 19 at 20:14
  • 1
    The hotfix is for the Model Service, which is implemented in Java only; even if you have a .NET Web Application, your Model Service will be Java. – Rick Pannekoek Nov 19 at 20:44
  • Thanks Rick. We received the Hotfix from SDL Customer Support and the issue is fixed after applying the hotfix. Thanks for your input we were able to fix the issue. – SRajeshK Nov 27 at 7:22

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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