3

I'm using Sitecore 9.2 scaled environment on Azure, and am trying to make a console application connects to XConnect, am following this link from Sitecore documentation.

In the part shown in the below code, I added the search indexer server URL in the searchWebAPIClient. However, I'm not sure what should be defined in the other 2 APIs (CollectionWebApiClient and ConfigurationWebApiClient). Also, where to define the reporting, ProcessingEngine, search indexer. server.

Can someone please advise?

var collectionClient = new CollectionWebApiClient(new Uri("https://collect.azurewebsites.net/odata"), clientModifiers, new[] { certificateModifier });
var searchClient = new SearchWebApiClient(new Uri("https://search.azurewebsites/odata"), clientModifiers, new[] { certificateModifier });
var configurationClient = new ConfigurationWebApiClient(new Uri("https://xconnect/configuration"), clientModifiers, new[] { certificateModifier });

var cfg = new XConnectClientConfiguration(
            new XdbRuntimeModel(CollectionModel.Model), collectionClient, searchClient, configurationClient);
  • Please add your code as text not an image. It gives the search engines more to crawl. – Richard Seal Nov 18 at 13:45
2

You just need to copy below two connection strings from CM app service to your console app to connect to XConnect.

<add name="xconnect.collection"                         connectionString="https://XXXXXXXX-xc-search.azurewebsites.net" />
<add name="xconnect.collection.certificate"             connectionString="blah;blah;" />

and then use xconnect.collection connectionstring in all 3 places as shown below-

var xdbCollectionCert = ConfigurationManager.ConnectionStrings["xconnect.collection.certificate"].ConnectionString;
var xdbClient = ConfigurationManager.ConnectionStrings["xconnect.collection"].ConnectionString;
var odataEndpoint = xdbClient + "/odata";
var collectionEndpoint = xdbClient + "/configuration";

var options = CertificateWebRequestHandlerModifierOptions.Parse(xdbCollectionCert);

var certificateModifier = new CertificateWebRequestHandlerModifier(options);

var clientModifiers = new List<IHttpClientModifier> { new TimeoutHttpClientModifier(new TimeSpan(0, 0, 20)) };

var collectionClient = new CollectionWebApiClient(new Uri(odataEndpoint), clientModifiers, new[] { certificateModifier });
var searchClient = new SearchWebApiClient(new Uri(odataEndpoint), clientModifiers, new[] { certificateModifier });
var configurationClient = new ConfigurationWebApiClient(new Uri(collectionEndpoint), clientModifiers, new[] { certificateModifier });

var cfg = new XConnectClientConfiguration(new XdbRuntimeModel(CollectionModel.Model), collectionClient, searchClient, configurationClient);
  • Thank you so much for your answer but I faced another issue when running the project it gives me an error saying (Sitecore.XConnect.XdbCollectionUnavailableException: 'An error occurred while sending the request.' InvalidOperationException: The certificate was not found.) do you know what is wrong – Fatema elsayed Nov 19 at 10:47
  • @Fatemaelsayed Did you install xConnect's client certificate on your local? To access XConnect from your local, you will require to install client cert or you need to set AllowInvalidCertificate to true which is not recommended. – Surya Nov 19 at 11:59
0

For all of three API's we need to give XConnect hostname only as I did below.

 var collectionClient = new Sitecore.XConnect.Client.WebApi.CollectionWebApiClient(new Uri("https://XConnect Site hostname/odata"), clientModifiers, new[] { certificateModifier });
 var searchClient = new Sitecore.XConnect.Client.WebApi.SearchWebApiClient(new Uri("https://XConnect Site hostname/odata"), clientModifiers, new[] { certificateModifier });
 var configurationClient = new Sitecore.XConnect.Client.WebApi.ConfigurationWebApiClient(new Uri("https://XConnect Site hostname/configuration"), clientModifiers, new[] { certificateModifier });

Please let me know if getting any issue with it.

  • As I mentioned am using a scaled sitecore environment, which means that the XConnect is divided into servers reporting, ProcessingEngine, search indexer... So I dont know which server URL to put in the CollectionWebApiClient, SearchWebApiClient, and ConfigurationWebApiClient – Fatema elsayed Nov 18 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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