I have the following association:
As we can see, users can have multiple email notifications and an email notification can have multiple users.
I'm trying to associate an email notification to a user. This is how I do:
var associate = { "@odata.id": "baseuri/.../systemusers(F71614E2-1EB3-E711-90F3-0050568B95ED)" }; var req = new XMLHttpRequest(); req.open("POST", encodeURI(baseuri/.../mkg_mkg_notificationemail_primaryrecipients$ref), true); req.setRequestHeader("Content-Type", "application/json"); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.onload = function () { if (req.readyState == 4) { }else{ } }; req.send(JSON.stringify(associate));
I get the following error:
{ "error":{ "code":"","message":"propertyValue (System.Uri) should be EdmEntityObjectCollection","innererror":{ "message":"propertyValue (System.Uri) should be EdmEntityObjectCollection","type":"Microsoft.Crm.CrmException" } } }
According to some answers on some similar posts, I reverse the entities (POST on systemusers with association of type email notification), but I get the following error:
{ "error":{ "code":"","message":"Invalid role specified for entity 'systemuser'in relationship 'mkg_mkg_notificationemail_primaryrecipients.Referencing'","innererror":{ "message":"Invalid role specified for entity 'systemuser'in relationship 'mkg_mkg_notificationemail_primaryrecipients.Referencing'","type":"System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]" } } }
Does anyone knows what is wrong ?
Thanks in advance !
*This post is locked for comments
Does anyone have solution for this error?
I am facing the same error when using "teammembership_association" with dynamics CRM web API. Please help
We are also running into an error associating N:N entities via the Web API. Most of the related forum posts we have came across suggest inverting the entities, but we are getting an error regardless of which side we treat as the parent. To rule out a one-off error with this N:N relationship, we've also tried creating a new N:N relationship between the same two entities, but get the same corresponding errors. Below are sample Web API calls and returned errors, as well as a screenshot of the relationship. Any help would be appreciated.
For screenshot please refer to the following link: community.dynamics.com/.../264061
Request 1:
POST https://{orgname}.crm.dynamics.com/api/data/v8.2/str_salesorders(3A79AAFD-1AB8-E611-80E8-FC15B428BC1C)/str_strsalesorder_systemuser/$ref HTTP/1.1
OData-Version: 4.0
OData-MaxVersion: 4.0
{"@odata.id":"https://{orgname}.crm.dynamics.com/api/data/v8.2/systemusers(5C44C50A-5FAC-4150-8BDB-D1950A412438)"}
Response 1:
HTTP/1.1 500 Internal Server Error
OData-Version: 4.0
{
"error":{
"code":"","message":"propertyValue (System.Uri) should be EdmEntityObjectCollection","innererror":{
"message":"propertyValue (System.Uri) should be EdmEntityObjectCollection","type":"Microsoft.Crm.CrmException","stacktrace":" at Microsoft.Crm.CrmException.Assert(Boolean condition, String message)\r\n at Microsoft.Crm.Extensibility.OData.TypeConverters.EdmEntityTypeConverter.SetNavigationPropertyToXrmEntity(Entity entity, EntityMetadata entityMetadata, IEdmProperty edmProperty, EntityRelationship entityRelationship, Object propertyValue, Nullable`1 role)\r\n at Microsoft.Crm.Extensibility.OData.TypeConverters.EdmEntityTypeConverter.ConvertToCrmTypeInternal(EdmEntityObject edmTypeValue)\r\n at Microsoft.Crm.Extensibility.OData.TypeConverters.EdmTypeConverterBase`2.ConvertToCrmType(Object edmTypeValue)\r\n at Microsoft.Crm.Extensibility.OData.EdmTypeConverter.ConvertToCrmEntity(EdmEntityObject edmEntity, EntityReference entityReference)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.UpdateResourceProperty(CrmODataExecutionContext context, String edmEntityName, String entityKeyValue, String propertyName, Object edmPropertyValue)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.UpdateResourceNavigationPropertyReference(CrmODataExecutionContext context, String edmEntityName, String entityKeyValue, String navigationPropertyName, CrmEdmEntityReference edmPropertyReference)\r\n at Microsoft.Crm.Extensibility.OData.EntityController.UpdateNavigationRefInternal(String entityName, String key, String navigation, Uri link)\r\n at Microsoft.Crm.Extensibility.OData.EntityController.PostNavigationRef(String entityName, String key, String navigation, Uri link)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\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.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.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.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__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 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
}
}
}
-----------
Request 2:
POST https://{orgname}.crm.dynamics.com/api/data/v8.2/systemusers(5C44C50A-5FAC-4150-8BDB-D1950A412438)/str_strsalesorder_systemuser/$ref HTTP/1.1
OData-Version: 4.0
OData-MaxVersion: 4.0
{"@odata.id":"https://{orgname}.crm.dynamics.com/api/data/v8.2/str_salesorders(3A79AAFD-1AB8-E611-80E8-FC15B428BC1C)"}
Response 2:
HTTP/1.1 400 Bad Request
OData-Version: 4.0
{
"error":{
"code":"","message":"Invalid role specified for entity 'systemuser'in relationship 'str_strsalesorder_systemuser.Referencing'","innererror":{
"message":"Invalid role specified for entity 'systemuser'in relationship 'str_strsalesorder_systemuser.Referencing'","type":"System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]","stacktrace":" at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.Associate(EntityReference entityReference, Relationship relationship, EntityReferenceCollection relatedEntities, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataExecutionContext.Associate(EntityReference entityReference, Relationship relationship, EntityReferenceCollection relatedEntities)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.UpdateResourceNavigationPropertyReference(CrmODataExecutionContext context, String edmEntityName, String entityKeyValue, String navigationPropertyName, CrmEdmEntityReference edmPropertyReference)\r\n at Microsoft.Crm.Extensibility.OData.EntityController.UpdateNavigationRefInternal(String entityName, String key, String navigation, Uri link)\r\n at Microsoft.Crm.Extensibility.OData.EntityController.PostNavigationRef(String entityName, String key, String navigation, Uri link)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\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.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.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.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__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 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
}
}
}
Thanks, i've already tried to swap the entities but does not work for me...
Hi,
Not sure but maybe this can helps you github.com/.../1
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156