Create a news item with the Fluent API

Use the code example below to create a news item and to set its ID, Title, and Content with the Fluent API.

NOTE: The ID argument is assigned to the master version of the news item. For more information about the different version of a news item, see For developers: Content lifecycle.

In the example below, you perform the following:
  1. Check whether a news item with the same ID already exists. 
  2. If it does not exist, create the news item by calling the CreateNew method of the singular news item facade. 
    The ID argument is assigned to the ID master version of the item. 
  3. Set the properties of the news item by calling the Do method of the facade. 
  4. Save the changes. 
  5. To publish the news item, call the MessageWorkflow method of the WorkflowManager class and pass the required parameters.
  1. Create a news item with the Fluent API

Was this article helpful?