Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sitecore XConnect: an error occurred when trying to create a controller of type 'ContactsController'

I'm experiencing an issue when calling my xConnect client in Sitecore 9, update 1. The initilization of the client object runs fine. But when I call a method on the client, I get this exception:


{
    "Message":"An error has occurred.",
    "ExceptionMessage":"An error occurred when trying to create a controller of type 'ContactsController'. 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)
   at Sitecore.XConnect.Web.DependencyInjection.WebApiServiceControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)
   at System.Web.Http.Controllers.HttpControllerDescriptor.CreateController(HttpRequestMessage request)
   at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()",
    "InnerException":{
        "Message":"An error has occurred.",
        "ExceptionMessage":"Type 'Sitecore.XConnect.Web.Controllers.ContactsController' does not have a default constructor",
        "ExceptionType":"System.ArgumentException",
        "StackTrace":"   at System.Linq.Expressions.Expression.New(Type type)
       at System.Web.Http.Internal.TypeActivator.Create[TBase](Type instanceType)
       at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(HttpRequestMessage request, Type controllerType, Func`1& activator)
       at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)"}}
like image 286
Jeroen De Clercq Avatar asked Nov 07 '22 11:11

Jeroen De Clercq


1 Answers

  1. Check if certificates have managed private keys for xconnect app pool in the MMC
  2. If the first point doesn't work now try following the power shell command:

Get-Childitem cert:\LocalMachine\root -Recurse | Where-Object {$_.Issuer -ne $_.Subject} | Move-Item -Destination Cert:\LocalMachine\CA

  1. If the second point did not work then check if the following two services are running: enter image description here
like image 137
Prashant Tomar Avatar answered Dec 08 '22 06:12

Prashant Tomar