I am implementing a taxonmy based navigation in SDL Web 8.5 with DXA 2.0. According to the documentation, I have created a category keyword with [Navigation] in its title.
I have published this Category and Keyword as well. In Unity.config, I have changed the mapping for INavigationProvider from Static to Dynamic as well.
<type type="INavigationProvider" mapTo="DynamicNavigationProvider">
<lifetime type="singleton" />
</type>
I expect to see NavigationLinks model to be populated. However, it never happens. I put some code in try and catch to see what is the exception.
public static NavigationLinks GetDynamicNavigationLinks(this HtmlHelper helper,string requestUrlPath,Localization localization)
{
try
{
INavigationProvider navigationProvider = SiteConfiguration.NavigationProvider;
var navigationLinks = navigationProvider.GetTopNavigationLinks(requestUrlPath, localization);
return navigationLinks;
}
catch(Exception exception)
{
throw exception;
}
}
The exception is as follows:
2018-07-20 09:47:49,337 [9] ERROR - DXA Model Service returned an unexpected response.
Sdl.Web.Common.DxaException: DXA Model Service returned an unexpected response. ---> Sdl.Web.ModelService.ModelServiceException: DXA Model Service returned an unexpected response from request 'http://webcmsnd.[domainName].org:8998/api/navigation/17' of . ---> System.ArgumentNullException: Value cannot be null.
Parameter name: value
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Sdl.Web.ModelService.ModelServiceClient.PerformRequest[T](IModelServiceRequest request)
--- End of inner exception stack trace ---
at Sdl.Web.ModelService.ModelServiceClient.PerformRequest[T](IModelServiceRequest request)
at Sdl.Web.Tridion.ModelService.DefaultModelServiceProvider.GetSitemapItem(Localization localization)
--- End of inner exception stack trace ---
at Sdl.Web.Tridion.ModelService.DefaultModelServiceProvider.GetSitemapItem(Localization localization)
at Sdl.Web.Tridion.Navigation.ModelServiceImpl.DynamicNavigationProvider.<>c__DisplayClass2_0.<GetNavigationModel>b__0()
at Sdl.Web.Tridion.Caching.CacheProvider.GetOrAdd[T](String key, String region, Func`1 addFunction, IEnumerable`1 dependencies)
at Sdl.Web.Tridion.Navigation.ModelServiceImpl.DynamicNavigationProvider.GetNavigationModel(Localization localization)
at Sdl.Web.Tridion.Navigation.ModelServiceImpl.DynamicNavigationProvider.GetBreadcrumbNavigationLinks(String requestUrlPath, Localization localization)
at Sdl.Web.Tridion.Navigation.DynamicNavigationProvider.GetBreadcrumbNavigationLinks(String requestUrlPath, Localization localization)
at Sdl.Web.Mvc.Controllers.NavigationController.Navigation(EntityModel entity, String navType, Int32 containerSize)
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
When I make the Get request to the Navigation API however, I get the data: Get -> http://webcmsnd.[domainName].org:8998/api/navigation/17
{
"Id":"t25583",
"Type":"TaxonomyNode",
"Title":"Dynamic [Navigation]",
"OriginalTitle":"Dynamic [Navigation]",
"Visible":false,
"Items":[
{
"$type":"TaxonomyNodeModelData",
"Id":"t25583-k232401",
"Type":"TaxonomyNode",
"Title":"Home",
"OriginalTitle":"000 Home",
"Visible":false,
"Items":[
{
"$type":"TaxonomyNodeModelData",
"Id":"t25583-k232404",
"Type":"TaxonomyNode",
"Title":"Articles",
"OriginalTitle":"010 Articles",
"Visible":false,
"Items":[
],
"Key":"010 Articles",
"HasChildNodes":false,
"Description":"Articles",
"IsAbstract":false,
"ClassifiedItemsCount":0
}
],
"Key":"000 Home",
"HasChildNodes":true,
"Description":"Home",
"IsAbstract":false,
"ClassifiedItemsCount":0
},
{
"$type":"TaxonomyNodeModelData",
"Id":"t25583-k232402",
"Type":"TaxonomyNode",
"Title":"Resource",
"OriginalTitle":"010 Resource",
"Visible":false,
"Items":[
],
"Key":"010 Resource",
"HasChildNodes":false,
"Description":"Resource",
"IsAbstract":false,
"ClassifiedItemsCount":0
},
{
"$type":"TaxonomyNodeModelData",
"Id":"t25583-k232403",
"Type":"TaxonomyNode",
"Title":"News",
"OriginalTitle":"020 News",
"Visible":false,
"Items":[
],
"Key":"020 News",
"HasChildNodes":false,
"Description":"News",
"IsAbstract":false,
"ClassifiedItemsCount":0
}
],
"Key":"",
"HasChildNodes":false,
"Description":"",
"IsAbstract":true,
"ClassifiedItemsCount":0
}
My questions are:
- What is the root cause of this exception? How can I resolve it?
- How can I customize the category keyword navigation to add customized fields and publishing them as JSON?