Trying to publish using Content Service

Hello all, I am trying to publish a node using the Content Service as part of a migration project to v15. I am following the steps in https://docs.umbraco.com/umbraco-cms/reference/management/using-services/contentservice but…

  1. Looks like SaveAndPublish is actually deprecated
  2. I am trying to use Publish instead but there is no indication as to why the content is not published (same as with SaveAndPublish), see screenshot:

Can anyone help / point me in the right direction? Doesn’t look like I can find anything in logs either.

May be you need to specifically save first?

1 Like

Thank you, that helped! It is now required to Save first and then Publish

var node = _contentService.CreateContent("Name of the node", parentUdi, "contentTypeAlias", request.UserId);

node.SetValue("description", "property description...");
var savedNode = _contentService.Save(node);
if (!savedNode.Success)
{
  throw new Exception("Error when saving node");
}
var publishedNode = _contentService.Publish(node, ["*"], request.UserId);
if (!publishedNode.Success)
{
  throw new Exception("Error when saving property group node");
}

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.