Copied to clipboard

Flag this post as spam?

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


  • nickornotto 317 posts 679 karma points
    May 10, 2019 @ 21:44
    nickornotto
    0

    Error on generating models in Umbraco 7.6 in ModelsBuilder API mode

    I have Umbraco 7.6

    I am trying to enable ModelsBuilder in API mode. As far as I learned in my version of umbraco Umbraco.ModelsBuilder.Api should have already been part of the Umbraco.Core and installed.

    However when I check in my Developer > ModelsBuilders tab I can see this:

    ModelsBuilder is enabled, with the following configuration:
    
    The models factory is enabled.
    The API is enabled but not installed.
    External tools such as Visual Studio cannot use the API.
    No models mode is specified: models will not be generated.
    Models namespace is Umbraco.Web.PublishedContentModels.
    Static mixin getters are enabled. The pattern for getters is "Get{0}".
    Tracking of out-of-date models is not enabled.
    

    In my web.config I have this:

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

    Since it says:

    The API is enabled but not installed.
    

    I tried to install Umbraco.ModelsBuilder.Api but have not found any information which ModelsBuilder versions are compatible with Umbraco 7.6 so I installed the latest 8.0.4 into my start Web project.

    I installed VS extension and created a separate project to hold models eg. MyProject.Umbraco.Models, right-clicked Builder.cs file and clicked 'Run custom tool' (which I previously set up in the Builder.cs properties.

    It does something but at the end it throws an error:

    UmbracoModelsBuilder: Starting v8.0.4 10/05/2019 18:29:01.
    UmbracoModelsBuilder: UmbracoModelsBuilder failed to generate code: UnsupportedMediaTypeException: No MediaTypeFormatter is available to read an object of type 'IDictionary`2' from content with media type 'text/html'.
    UmbracoModelsBuilder:    at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)
       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)
    

    Anyone can help with this?

  • Simon Dingley 1431 posts 3332 karma points c-trib
    Feb 13, 2020 @ 09:51
    Simon Dingley
    0

    Versions

    Several version of Models Builder have existed:

    Version 2.x (and older) are old, obsolete versions of Zbu.ModelsBuilder Version 3.x is the current version of Umbraco.ModelsBuilder for Umbraco 7 Version 8.x is the current version of Umbraco.ModelsBuilder for Umbraco 8

    Borrowed from the readme on https://github.com/zpqrtbnk/Zbu.ModelsBuilder

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies