I am getting an exception/error while I am creating contact though xConnect Code,
below is my code:
using (var client = CreateClient())
{
try
{
var source = "Subcribe.Form";
var id = CurrentTracker.Contact.ContactId.ToString("N");
CurrentTracker.Session.IdentifyAs(source, id);
var trackerIdentifier = new IdentifiedContactReference(source, id);
var expandOptions = new ContactExpandOptions(
CollectionModel.FacetKeys.PersonalInformation,
CollectionModel.FacetKeys.EmailAddressList);
Contact contact = client.Get(trackerIdentifier, expandOptions);
SetPersonalInformation(GetValue(firstNameField), GetValue(lastNameField), contact, client);
SetEmail(GetValue(emailField), contact, client);
client.Submit();
return true;
}
catch (Exception ex)
{
Logger.LogError(ex.Message, ex);
return false;
}
}
I am getting error on client.Submit()
method , as below:
Exception: Sitecore.XConnect.XdbCollectionUnavailableException
Message: {
"Message": "Operation failed: One or more dependencies failed",
"ExceptionMessage": "One or more dependencies failed",
"ExceptionType": "Sitecore.XConnect.Operations.DependencyFailedException",
"StackTrace": null,
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "Scaled database was not configured properly: the range shard map has to be configured.",
"ExceptionType": "Sitecore.Xdb.Collection.Failures.ScaledDatabaseConfigurationException",
"StackTrace": " at Sitecore.Xdb.Collection.Data.SqlServer.Configuration.ElasticScaleConnectionManager.GetRangeShardMap(String rangeShardMapName)\r\n at Sitecore.Xdb.Collection.Data.SqlServer.Configuration.ElasticScaleConnectionManager.<>c__DisplayClass37_0.<GetRangeMappings>b__0()\r\n at System.Lazy`1.CreateValue()\r\n at System.Lazy`1.LazyInitValue()\r\n at Sitecore.Xdb.Collection.Data.SqlServer.Configuration.MemoryCacheManager.AddOrGetExistingFromCache[T](String key, Func`1 valueFactory)\r\n at Sitecore.Xdb.Collection.Data.SqlServer.Configuration.ElasticScaleConnectionManager.MapKeysToShards[TPartitionKey,TEntityKey](String rangeShardMapName, IReadOnlyCollection`1 keys)\r\n at Sitecore.Xdb.Collection.Data.SqlServer.Managers.SqlDataRecordsManager`2.<GetAsync>d__49.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Sitecore.Xdb.Collection.Data.SqlServer.SqlDataProvider.<GetDeviceProfilesById>d__13.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Linq.AsyncEnumerable.<>c__DisplayClass440_0`1.<<ToAsyncEnumerable>b__1>d.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Linq.AsyncEnumerable.AnonymousAsyncIterator`1.<MoveNextCore>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Linq.AsyncEnumerable.AsyncIterator`1.<MoveNext>d__10.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Linq.AsyncEnumerable.SelectManyAsyncIterator`2.<MoveNextCore>d__10.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Linq.AsyncEnumerable.AsyncIterator`1.<MoveNext>d__10.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Linq.AsyncEnumerable.<ForEachAsync_>d__174`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Sitecore.XConnect.Service.RepositoryGetInvoker.<UpdateGetOperations>d__7`2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Sitecore.XConnect.Service.RepositoryGetInvoker.<>c__DisplayClass4_1.<<Execute>b__19>d.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Sitecore.XConnect.Service.RepositoryGetInvoker.<FailOperationsOnException>d__5.MoveNext()"
}
}
Source: Sitecore.Xdb.Common.Web
at Sitecore.Xdb.Common.Web.Synchronous.SynchronousExtensions.SuspendContextLock[TResult](Func`1 taskFactory)
at Sitecore.XConnect.Client.XConnectSynchronousExtensions.SuspendContextLock[TResult](Func`1 taskFactory)
at Sitecore.XConnect.Client.XConnectSynchronousExtensions.Get[TEntity](IXdbContext context, IEntityReference`1 reference, ExpandOptions expandOptions, TimeSpan timeout)
at Sitecore.Analytics.XConnect.DataAccess.XConnectDataAdapterProvider.<>c__DisplayClass26_0.<GetDevice>b__1(IXdbContext xdbContext)
at Sitecore.Analytics.XConnect.DataAccess.XConnectDataAdapterProvider.ExecuteWithExceptionHandling[T](Func`2 func)
I checked the xConnect collection URL and its up and running as below:
Below is my connection string for xconnect collection:
<add name="xconnect.collection" connectionString="https://Sitecore9.Xconnect" />