0

I am currently endeavouring to develop an application for data extraction via XConnect. Regrettably, an error is impeding progress at the "await cfg.InitializeAsync();" segment of the code. After reviewing the content available at xConnect The HTTP response was not successful: Unauthorized I have determined that the issue discussed does not align with the specific challenge I am currently encountering.

Below, the exception stack is provided for further review and analysis.

Sitecore.XConnect.XdbCollectionUnavailableException
  HResult=0x80131500
  Message=An error occurred while sending the request.
  Source=Sitecore.XConnect.Client
  StackTrace:
   at Sitecore.XConnect.Client.WebApi.ConfigurationWebApiClient.<Refresh>d__6.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Sitecore.XConnect.Client.XConnectClientConfiguration.<InitializeAsync>d__32.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Sitecore.TechnicalMarketing.xConnectTutorial.Program.<MainAsync>d__1.MoveNext() in C:\Users\26384\source\repos\SitecoreDataExtraction\XConnectTutorial\xConnectTutorial\Program.cs:line 42
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
   at Sitecore.TechnicalMarketing.xConnectTutorial.Program.Main(String[] args) in C:\Users\26384\source\repos\SitecoreDataExtraction\XConnectTutorial\xConnectTutorial\Program.cs:line 20

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
HttpRequestException: An error occurred while sending the request.

Inner Exception 2:
WebException: The underlying connection was closed: An unexpected error occurred on a receive.

Inner Exception 3:
Win32Exception: The credentials supplied to the package were not recognized

I have provided only the URL of the xConnect website that is hosted on my IIS from the supplied credentials.

given below is the code for creating xConnectClientCongiguration:

public virtual XConnectClientConfiguration GetClientConfiguration(string collectionHost, string searchHost, string configHost, string thumbprint)
{
    //Set up the certificate used to connect to xConnect endpoints
    var options = CertificateHttpClientHandlerModifierOptions.Parse("StoreName=My;StoreLocation=LocalMachine;FindType=FindByThumbprint;FindValue=" + thumbprint);
    var certificateModifier = new CertificateHttpClientHandlerModifier(options);

    //Set up timeout modifier for the client
    var timeoutClientModifier = new TimeoutHttpClientModifier(new TimeSpan(0, 0, 20));
    var clientModifiers = new List<IHttpClientModifier>
    {
        timeoutClientModifier
    };

//Initialize the clients. Each requires the certificate in order to open the connection
    var collectionClient = new CollectionWebApiClient(new Uri(collectionHost + "/odata"), clientModifiers, new[] { certificateModifier });
     var searchClient = new SearchWebApiClient(new Uri(searchHost + "/odata"), clientModifiers, new[] { certificateModifier });
    var configurationClient = new ConfigurationWebApiClient(new Uri(configHost + "/configuration"), clientModifiers, new[] { certificateModifier });

//Create the configuration object with all clients
var cfg = new XConnectClientConfiguration(
                new XdbRuntimeModel(CollectionModel.Model), collectionClient, searchClient, configurationClient);

 //Test configuration
 var outputHandler = new OutputHandler();
 try
 {
    await cfg.InitializeAsync();

    // Print xConnect validation message if configuration is valid
    outputHandler.WriteValidationMessage();
 }
 catch (XdbModelConflictException ce)
 {
    outputHandler.WriteError("Error initializing configuration", ce);
    return;
 }
}

I am getting error on

await cfg.InitializeAsync();

1 Answer 1

0

Can you check you are running in an admin mode and following app pools are assigned to the XConnect certificate.

  • Service
  • IUSR
  • Network Service
  • IIS_IUSRS
  • Local Service

enter image description here

Once the app pool roles assigned to the certificate, restart the app-pool. Hope this helps!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.