Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jeroen Vantroyen 54 posts 394 karma points c-trib
    Jun 12, 2019 @ 12:56
    Jeroen Vantroyen
    0

    ModelsBuilder API error in Umbraco V8

    I just deployed a new Umbraco 8 locally (8.0.2). I added ModelsBuilder.API 8.0.4 and enabled the API.

    I know I finally got the settings correct, because initially the API gave me a 404, but now it's being called, yet giving an internal exception.

      <add key="Umbraco.ModelsBuilder.Enable" value="true" />
      <add key="Umbraco.ModelsBuilder.EnableApi" value="true" />
      <add key="Umbraco.ModelsBuilder.ModelsMode" value="Nothing" />
      <add key="Umbraco.ModelsBuilder.LanguageVersion" value="CSharp6" />
    

    When I try to run the ModelsBuilder tool (also version 8.0.4), I get an exception:

      UmbracoModelsBuilder: Starting v8.0.4 12/06/2019 14:32:10.
      UmbracoModelsBuilder: UmbracoModelsBuilder failed to generate code: Exception: Response status code does not indicate success (InternalServerError)
      {"Message":"An error has occurred.","ExceptionMessage":"Object reference not set to an instance of an object.","ExceptionType":"System.NullReferenceException","StackTrace":"   at Umbraco.Web.PropertyEditors.ValueConverters.NestedContentManyValueConverter.GetPropertyValueType(PublishedPropertyType propertyType)\r\n   at Umbraco.Core.Models.PublishedContent.PublishedPropertyType.InitializeLocked()\r\n   at Umbraco.Core.Models.PublishedContent.PublishedPropertyType.Initialize()\r\n   at Umbraco.ModelsBuilder.Umbraco.UmbracoServices.GetTypes(PublishedItemType itemType, IContentTypeComposition[] contentTypes) in D:\\d\\Zbu ModelsBuilder\\src\\Umbraco.ModelsBuilder\\Umbraco\\UmbracoServices.cs:line 164\r\n   at Umbraco.ModelsBuilder.Umbraco.UmbracoServices.GetAllTypes() in D:\\d\\Zbu ModelsBuilder\\src\\Umbraco.ModelsBuilder\\Umbraco\\UmbracoServices.cs:line 39\r\n   at Umbraco.ModelsBuilder.Api.ApiHelper.GetModels(UmbracoServices umbracoServices, String modelsNamespace, IDictionary`2 files) in D:\\d\\Zbu ModelsBuilder\\src\\Umbraco.ModelsBuilder\\Api\\ApiHelper.cs:line 13\r\n   at Umbraco.ModelsBuilder.Api.ModelsBuilderApiController.GetModels(GetModelsData data) in D:\\d\\Zbu ModelsBuilder\\src\\Umbraco.ModelsBuilder.Api\\ModelsBuilderApiController.cs:line 87\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.<GetExecutor>b__2(Object instance, Object[] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()"}
      UmbracoModelsBuilder: at Umbraco.ModelsBuilder.Api.ApiClient.EnsureSuccess(HttpResponseMessage result)
         at Umbraco.ModelsBuilder.Api.ApiClient.GetModels(Dictionary`2 ourFiles, String modelsNamespace)
         at Umbraco.ModelsBuilder.CustomTool.CustomTool.UmbracoModelsBuilder.GenerateRaw(String wszInputFilePath, String wszDefaultNamespace, IntPtr[] rgbOutputFileContents, UInt32& pcbOutput, String& errMsg)
    

    Does anyone have a clue what this might be?

  • Rhys Hamilton 140 posts 942 karma points
    Jun 12, 2019 @ 14:02
    Rhys Hamilton
    0

    It looks to me like there's an issue around your Nested Content.

    My best guess is that the Nested Content consists of a Model that isn't available / generated when it's trying to be accessed (hence it throws a null exception), but that might not be the case.

    There's a similar sort of issue with Nested Content in V8 here, which might help a bit.

  • Jeroen Vantroyen 54 posts 394 karma points c-trib
    Jun 12, 2019 @ 14:20
    Jeroen Vantroyen
    1

    Thanks Rhys,

    this put me on the right track! I have one Nested Content datatype without any document types associated. Did not spot that one when I checked if the migration to V8 had worked.

    Turns out I am unable to associate it with any document types. The call to /umbraco/backoffice/UmbracoApi/NestedContent/GetContentTypes is simply returning an empty array.

    Thanks for the extra set of eyes!

  • Rhys Hamilton 140 posts 942 karma points
    Jun 12, 2019 @ 15:18
    Rhys Hamilton
    100

    No problem, I'm glad it pointed you in the right direction.

    Just incase this also helps, be sure to mark document types that you want to use in Nested Content as Published Elements by navigating to permissions and checking the appropriate "Is an Element type..." checkbox.

    In doing so, you should see a list of options to populate your nested content with.

    As such, the following api call /umbraco/backoffice/UmbracoApi/NestedContent/GetContentTypes should return available types and not an empty array.

  • Jeroen Vantroyen 54 posts 394 karma points c-trib
    Jun 12, 2019 @ 15:27
    Jeroen Vantroyen
    1

    Exactly what I discovered not a few minutes ago, but you beat me to the punch.

    ModelsBuilder started working after I fixed the datatype with the NestedContent.

    Thanks a lot!

Please Sign in or register to post replies

Write your reply to:

Draft