Copied to clipboard

Flag this post as spam?

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


  • Damien 36 posts 162 karma points
    Jul 17, 2019 @ 08:34
    Damien
    1

    V8.1 Umbraco.ContentAtXPath Bug?

    Hi,

    I'm working on a UmbracoAPIController, something which worked fine in v7 seems to have trouble in v8.1

    var a = Umbraco.ContentAtXPath("//docType[@isDoc]");

    Results in:

    System.ArgumentNullException: 'Value cannot be null. Parameter name: doc'

    var b = Umbraco.Content(1234);

    This is the same content and works fine.

    The content in question has no doctype props. Just a name and assigned template.

    Stack Trace:

    at Umbraco.Web.Macros.PublishedContentHashtableConverter..ctor(IPublishedContent doc) in d:\a\1\s\src\Umbraco.Web\Macros\PublishedContentHashtableConverter.cs:line 57 at Umbraco.Web.Macros.MacroRenderer.Render(String macroAlias, IPublishedContent content, IDictionary2 macroParams) in d:\a\1\s\src\Umbraco.Web\Macros\MacroRenderer.cs:line 200 at Umbraco.Web.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.<>c__DisplayClass4_1.b__1(String macroAlias, Dictionary2 macroAttributes) in d:\a\1\s\src\Umbraco.Web\PropertyEditors\ValueConverters\RteMacroRenderingValueConverter.cs:line 56 at Umbraco.Web.Macros.MacroTagParser.ParseMacros(String text, Action1 textFoundCallback, Action2 macroFoundCallback) in d:\a\1\s\src\Umbraco.Web\Macros\MacroTagParser.cs:line 194 at Umbraco.Web.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.RenderRteMacros(String source, Boolean preview) in d:\a\1\s\src\Umbraco.Web\PropertyEditors\ValueConverters\RteMacroRenderingValueConverter.cs:line 51 at Umbraco.Web.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, Object source, Boolean preview) in d:\a\1\s\src\Umbraco.Web\PropertyEditors\ValueConverters\RteMacroRenderingValueConverter.cs:line 81 at Umbraco.Core.Models.PublishedContent.PublishedPropertyType.ConvertSourceToInter(IPublishedElement owner, Object source, Boolean preview) in d:\a\1\s\src\Umbraco.Core\Models\PublishedContent\PublishedPropertyType.cs:line 208 at Umbraco.Web.PublishedCache.NuCache.Property.GetInterValue(String culture, String segment) in d:\a\1\s\src\Umbraco.Web\PublishedCache\NuCache\Property.cs:line 192 at Umbraco.Web.PublishedCache.NuCache.Property.GetXPathValue(String culture, String segment) in d:\a\1\s\src\Umbraco.Web\PublishedCache\NuCache\Property.cs:line 232 at Umbraco.Web.PublishedCache.NuCache.Navigable.NavigableContent.Value(Int32 index) in d:\a\1\s\src\Umbraco.Web\PublishedCache\NuCache\Navigable\NavigableContent.cs:line 74 at Umbraco.Core.Xml.XPath.NavigableNavigator.MoveToFirstChildProperty() in d:\a\1\s\src\Umbraco.Core\Xml\XPath\NavigableNavigator.cs:line 602 at Umbraco.Core.Xml.XPath.NavigableNavigator.MoveToFirstChild() in d:\a\1\s\src\Umbraco.Core\Xml\XPath\NavigableNavigator.cs:line 562 at MS.Internal.Xml.XPath.XPathDescendantIterator.MoveNext() at MS.Internal.Xml.XPath.DescendantQuery.Advance() at MS.Internal.Xml.XPath.FilterQuery.Advance() at MS.Internal.Xml.XPath.XPathSelectionIterator.MoveNext() at Umbraco.Web.PublishedCache.NuCache.ContentCache.d31.MoveNext() in d:\a\1\s\src\Umbraco.Web\PublishedCache\NuCache\ContentCache.cs:line 358 at DITAppService.Controllers.KickstartQuestionsController.GetKickstartQuestions() in C:\Users\dpuddifoot\Source\Repos\DITExportingGreatAppService\DITAppService\DITAppService\Controllers\KickstartQuestionsController.cs:line 27 at lambdamethod(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>cDisplayClass62.b__2(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)

  • Damien 36 posts 162 karma points
    Jul 17, 2019 @ 08:52
    Damien
    0

    Tried using DI for context.

    GetByXpath failed with same error.

    However GetByContentType worked

    using (var ctx = _context.EnsureUmbracoContext())
                {
                    var content = ctx.UmbracoContext.Content.GetByContentType(YourModel.GetModelContentType());
                }
    
  • Niels Swimberghe 22 posts 105 karma points c-trib
    Aug 18, 2019 @ 03:07
    Niels Swimberghe
    0

    I'm migrating from 7 to 8 and the same issue is popping up anytime an RTE field has to be rendered. I noticed my macro was using Umbraco.TextboxMultiple instead of the new alias Umbraco.TextArea. After changing the Macro Parameter Editor to Umbraco.TextArea, nothing changed unfortunately, but it may be related... not sure.

    I submitted an issue on GitHub.

  • George Phillipson 108 posts 287 karma points
    Aug 19, 2019 @ 23:03
    George Phillipson
    0

    Have you tried

    public IEnumerable<IPublishedContent> ContentOfHomePage()
            {
                return _contextFactory.EnsureUmbracoContext().UmbracoContext.Content.GetByXPath("//home").ToList();
            }
    
            public IEnumerable<IPublishedContent> RetrieveDataViaGetXPath(UmbracoContext context, string doctype)
            {
                string retriveDocType = $"//{doctype}";
                 return context.Content.GetByXPath(retriveDocType).ToList();
            }
    

    Both work fine for me

  • Niels Swimberghe 22 posts 105 karma points c-trib
    Aug 20, 2019 @ 01:38
    Niels Swimberghe
    0

    Using .ToList() was absolutely necessary on other places in my code. Though it didn't resolve the issue in this location.
    Using umbracoContext.Content.GetByRoute(...); did work as an alternative querying method. This was suggested by Sebastiaan on the GitHub link above.

  • Zachary Allen 14 posts 85 karma points
    Nov 18, 2019 @ 21:51
    Zachary Allen
    0

    I'm getting this same error when trying to render Rich Text area content to an API Controller.

    The Error only happens when the Rich Text Area contains a Macro. If its just plain text the API controller works just fine.

    I've also noticed if I render the content through a normal view first, the API controller will work after that until the node is republished.

  • Niels Swimberghe 22 posts 105 karma points c-trib
    Nov 18, 2019 @ 23:14
    Niels Swimberghe
    0

    Which version of umbraco are you on?

  • Zachary Allen 14 posts 85 karma points
    Nov 18, 2019 @ 23:31
    Zachary Allen
    0

    Was on 8.1.0, just upgraded to 8.3.0. Still seeing the issue, but may need to republish all the content or macro definitions to fix it

  • Niels Swimberghe 22 posts 105 karma points c-trib
    Nov 19, 2019 @ 15:25
    Niels Swimberghe
    0

    The same issue I was encountering was fixed in 8.1.4. Try republishing. GitHub issue here.

Please Sign in or register to post replies

Write your reply to:

Draft