Create content items via the API

2025/09/16 9:09 AM

Hello,

I'm building an importer that needs to create reusable content items using the API. I'm following the API documentation, https://docs.kentico.com/api/content-management/content-items

I get a runtime error when starting my application locally, Unable to resolve service for type 'CMS.ContentEngine.IContentItemManager' while attempting to activate 'Infrastructure.Repositories.LocationRepository'

In my LocationRepository class I have initialized all of the services outlined in the documentation. I must be missing something in my Program.cs but I can't tell from the documentation. Has anyone built functionality to create content items via the API?


Environment

  • Xperience by Kentico version: [30.9.0]

  • .NET version: [8|9]

  • Execution environment: [SaaS|Private cloud (Azure/AWS/Virtual machine)]

  • Link to relevant Xperience by Kentico documentation

Tags:
Content types v30.8.0 C#

Answers

2025/09/17 3:13 PM
Accepted answer

You need to use the factory to create the manager. There's an example of doing this with web pages in the Kentico Community Portal.

There's also an example of doing it for reusable content items that's a bit more complex with some layers of abstraction.

But, the general idea is:

  1. Inject the IContentItemManagerFactory into your code.
  2. Call contentItemManagerfactory.Create() with the administration user that will be attributed as the creator of the content item to create the IContentItemManager.
  3. Call manager.Create(parameters, data) to create the content item.

To response this discussion, you have to login first.