Basically, I need to make API POST method that'll, when called, create new child node (just like you can do in the Umbraco backoffice) from JSON that's passed in the request body and from what I've seen, I need ContentService in order to make that possible (if there's a better way to do that, please post it). Thanks in advance!
EDIT: I've solved that error by putting contentService in the POST method body (I've declared it globally first).
A field initializer cannot reference the non-static field, method, or property 'UmbracoApiControllerBase.Services'
I'm making an Web API that needs to have CRUD methods and I'm stuck at POST. One of the reasons is the title error that I get with this line of code:
IContentService contentService = Services.ContentService;
I've pasted that line from this link: https://our.umbraco.com/documentation/Reference/Management/Services/ConsentService/
Basically, I need to make API POST method that'll, when called, create new child node (just like you can do in the Umbraco backoffice) from JSON that's passed in the request body and from what I've seen, I need ContentService in order to make that possible (if there's a better way to do that, please post it). Thanks in advance!
EDIT: I've solved that error by putting contentService in the POST method body (I've declared it globally first).
Do you want the ConsentService or the ContentService? You are linking to the ConsentService.
But you can use the following: IContentService contentService = ApplicationContext.Current.Services.ContentService;
Hi Pedrag,
Could you post the code of your api controller.
Dave
is working on a reply...