Try our conversational search powered by Generative AI!

Can't search using the Content Search API. Does an instance of IContentApiSearchProvider exists, or do I write my own?


I have installed the Content Delivery API in my solution, and everytime I generate a search request in Postman, I get an error saying:

"ExceptionMessage": "An error occurred when trying to create a controller of type 'ContentApiSearchController'. Make sure that the controller has a parameterless public constructor."

And this is due to the fact that no instance of IContentApiSearchProvider has been added to the dependency resolver.

According to the Episerver documentation, the Content Search API makes use of Episerver Find to query content, and I have Episerver Find installed in my solution. Is there anything, that I might have missed here?

Jun 20, 2019 16:33


Do you see any errors in log file ?

And can you show your packages.config file ?

Jun 21, 2019 12:16

I can post the stack trace I get when I make a request with Postman. Seems like it can't find the System.Linq reference, even though I can see it in my packages.config file

"Message": "An error has occurred.",
"ExceptionMessage": "An error occurred when trying to create a controller of type 'ContentApiSearchController'. Make sure that the controller has a parameterless public constructor.",
"ExceptionType": "System.InvalidOperationException",
"StackTrace": " at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)\r\n at System.Web.Http.Controllers.HttpControllerDescriptor.CreateController(HttpRequestMessage request)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()",
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "Activation error occurred while trying to get instance of type IContentApiSearchProvider, key \"\"",
"ExceptionType": "EPiServer.ServiceLocation.ActivationException",
"StackTrace": " at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)\r\n at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService]()\r\n at EPiServer.ContentApi.Search.Controllers.ContentApiSearchController..ctor()\r\n at lambda_method(Closure )\r\n at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)",
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "Error while building type EPiServer.ContentApi.Search.Internal.FindODataParser. See the inner exception for details\r\n1.) new FindODataParser(*Default of IClient*)\r\n2.) EPiServer.ContentApi.Search.Internal.FindODataParser\r\n3.) Instance of EPiServer.ContentApi.Search.Internal.IFindODataParser (EPiServer.ContentApi.Search.Internal.FindODataParser)\r\n4.) new FindContentApiSearchProvider(*Default of IClient*, *Default of IContentModelMapperFactory*, *Default of ContentApiSearchConfiguration*, *Default of ContentApiConfiguration*, *Default of IFindODataParser*, *Default of RoleService*)\r\n5.) EPiServer.ContentApi.Search.Internal.FindContentApiSearchProvider\r\n6.) Instance of EPiServer.ContentApi.Search.IContentApiSearchProvider (EPiServer.ContentApi.Search.Internal.FindContentApiSearchProvider)\r\n7.) Container.GetInstance(EPiServer.ContentApi.Search.IContentApiSearchProvider)\r\n",
"ExceptionType": "StructureMap.Building.StructureMapBuildException",
"StackTrace": " at lambda_method(Closure , IBuildSession , IContext )\r\n at StructureMap.Building.BuildPlan.Build(IBuildSession session, IContext context)\r\n at StructureMap.SessionCache.GetObject(Type pluginType, Instance instance, ILifecycle lifecycle)\r\n at StructureMap.SessionCache.GetDefault(Type pluginType, IPipelineGraph pipelineGraph)\r\n at StructureMap.Container.GetInstance(Type pluginType)\r\n at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)",
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "Could not load file or assembly 'System.Linq, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.",
"ExceptionType": "System.IO.FileNotFoundException",
"StackTrace": " at Microsoft.OData.Edm.EdmModel..ctor()\r\n at System.Web.OData.Builder.EdmModelHelperMethods.BuildEdmModel(ODataModelBuilder builder)\r\n at System.Web.OData.Builder.ODataConventionModelBuilder.GetEdmModel()\r\n at EPiServer.ContentApi.Search.Internal.FindODataParser..ctor(IClient searchClient)\r\n at lambda_method(Closure , IBuildSession , IContext )"

Jun 21, 2019 12:50
Jun 21, 2019 21:08

I think the root cause was "Could not load file or assembly 'System.Linq, Version=, Culture=neutral, "

Check bindingRedirect in web.config.

This error may be due to DLL version mismatch. Try to delete bin folder and rebuild the application.

Jun 24, 2019 8:52

Hi Yusof,

I think you are using Parametrized Constructor in your ApiController.
If you fail to use the Interface components in your Api controller functions means the error will occur.

'ContentApiSearchController'. Make sure that the controller has a parameterless public constructor."


public class ContentApiSearchController: ApiController
        private readonly IContentLoader contentLoader;
        private readonly IUnitOfWork uow;
        public ContentApiSearchController(
            IContentLoader contentLoader,
            IUnitOfWork uow)
            this.contentLoader = contentLoader;
            this.uow = uow;

The contentloader and uow Interface componenets initialized in Api controller itself, If the contentloader or uow not used menas the error occured.

Jun 30, 2019 11:02
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.