For developers: Create a news item with the Native API
Use the code example below to create a news item and to set its ID, Title, and Content with the Native 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:
- Get an instance of the NewsManager class.
- Check whether a news item with the same ID already exists.
If it does not exist, create the news item by calling the CreateNewsItem method of the NewsManager class.
You can create a news item with either predefined or auto-generated ID, depending which overload of the method you use. The ID argument is assigned to the ID property of the master version of the item.
- Set the properties of the news item object.
- Save the changes.
- To publish the news item in live state, call the MessageWorkflow method of the WorkflowManager class and pass the required parameters.
Create a news item with the Native API