I have the same issue inside UmbracoApiController.
Furthermore I noticed there isn't any SaveAndPublish method like when using ContentService inside a razor file inherited from Umbraco.Web.Mvc.UmbracoTemplatePage, but it has a SaveAndPublishWithStatus method.
In razor template it used ContentService from ApplicationContext.Current.Services.ContentService, in WebApi controller just from Services.ContentService
I can access the SetValue method via IntelliSense, but it seems to fail it this case. It works if I use the following instead:
From another post that I just stumbled on.... I know it's a super old question, but anyone still on 7 that runs into this issue as I just did on an old instance - just explicitly cast your values to string instead of using var. The error message is misleading...I think when dynamic runs into ints (for example) it is not casting them correctly to the destination property type. Simply casting to string to match your property's expected type will allow you to continue to use .SetValue().
Umbraco.Core.Models.IContent Does not contain a definition for SetValue
In my controller i am trying to update a node like this
this works fine.
but when i get to
then i get the error
Umbraco.Core.Models.IContent Does not contain a definition for SetValue
Anyone know what the problem might be ?
I did some debugs and i can see that all information that is passed into the controller is correct
Figured it out, for some reason, SetValue cannot be used so instead i found i could use opdatereHold.Properties["holdNavn"].Value = clubTitle;
Could you figure out the problem with SetValue? I'm facing with the same issue.
The traditional method: opdatereHold.Properties["holdNavn"].Value = clubTitle; worked like a charm, but should we use this one instead of SetValue?
Im on the same road now :D
But did anyone find out what to use ?
I have the same issue inside UmbracoApiController. Furthermore I noticed there isn't any SaveAndPublish method like when using ContentService inside a razor file inherited from
Umbraco.Web.Mvc.UmbracoTemplatePage
, but it has a SaveAndPublishWithStatus method.In razor template it used ContentService from
ApplicationContext.Current.Services.ContentService
, in WebApi controller just fromServices.ContentService
I can access the SetValue method via IntelliSense, but it seems to fail it this case. It works if I use the following instead:
/Bjarne
From another post that I just stumbled on.... I know it's a super old question, but anyone still on 7 that runs into this issue as I just did on an old instance - just explicitly cast your values to string instead of using var. The error message is misleading...I think when dynamic runs into ints (for example) it is not casting them correctly to the destination property type. Simply casting to string to match your property's expected type will allow you to continue to use .SetValue().
Cheers,'
Jamie
is working on a reply...