Copied to clipboard

Flag this post as spam?

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


  • Karl Kopp 121 posts 227 karma points
    Apr 03, 2014 @ 08:16
    Karl Kopp
    0

    Using the Web API

    Hi All!

    Love the Grid Data type - does exactly what I need :) I'm trying to import content into Umbraco using the Web API and I'm struggling to set the Grid Data Type properly. I've tried an object but its failed. Code below is what I'm using. Any advice??

            IContent venue;
            venue = contentService.GetById(venueId);
    
            var special = new Special();
    
            special.featureBeer = beer;
            special.isMonday = monday;
            special.summary = summary;
    
            venue.SetValue("specials", special);
            contentService.SaveAndPublish(venue);
    

    Error: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The best overloaded method match for 'Umbraco.Core.Models.ContentBase.SetPropertyValue(string, string)' has some invalid arguments at CallSite.Target(Closure , CallSite , Object , String , Object ) at Umbraco.Core.Models.ContentBase.SetValue(String propertyTypeAlias, Object value)

    Any advice/help would be greatly appreciated :)

  • Stephen Roberts 47 posts 516 karma points c-trib
    Apr 04, 2014 @ 11:14
    Stephen Roberts
    0

    haveyou tried serializing to JSON before inserting? also I think it will have to be a List<Special> as this datatype allows a list of values to be used.

  • Karl Kopp 121 posts 227 karma points
    Apr 29, 2014 @ 04:45
    Karl Kopp
    0

    Thanks Stephen - I ended up attaching a debugger and seeing the JSON, so manage to use that and it worked a treat :)

    Cheers!

Please Sign in or register to post replies

Write your reply to:

Draft