I'm trying to call SendEmailFromTemplate via Web API and am constantly getting "Required field 'RegardingType' is missing".
I've already tried a few variations but I can't seem to find a way to pass this missing field
I'm calling this aciton as :
/api/data/v8.2/SendEmailFromTemplate
{
"TemplateId":"CD512306-14D6-E711-80CE-00155D016797",
"Regarding":
{
"@odata.type": "Microsoft.Dynamics.CRM.opportunity",
"@odata.id": "e63d7331-8bcb-e711-80cd-00155d016797"
},
"Target":
{
"@odata.type": "Microsoft.Dynamics.CRM.email",
"@odata.id": "d34e3955-59d6-e711-80ce-00155d016797"
}
}
|
but getting the error below:
{"error": {
"code": "",
"message": "Required field 'RegardingType' is missing",
"innererror": {
"message": "Required field 'RegardingType' is missing",
"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.Execute(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode, ExecutionContext executionContext)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataExecutionContext.Execute(OrganizationRequest request, ExecutionContext executionContext)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.ExecuteOperation(CrmODataExecutionContext context, EdmOperation edmOperation, Dictionary`2 parameters, Dictionary`2 boundParameters)\r\n at Microsoft.Crm.Extensibility.OData.ActionController.ProcessOperationRequest(String operationName, Dictionary`2 operationParameters, EntityReference entityReference, String boundEntityName, String boundEntityType)\r\n at Microsoft.Crm.Extensibility.OData.ActionController.PostUnboundAction(String operationName, ODataUntypedActionParameters parameters)\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.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.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.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.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
}
}}
|
can't seem to be able to understand how to send RegardingType field
I tried the variations bellow but all return the same message:
{ "TemplateId":"CD512306-14D6-E711-80CE-00155D016797", "Regarding": [ { "opportunityid@odata.bind": "/opportunities(e63d7331-8bcb-e711-80cd-00155d016797)" } ], "Target": [ { "activityid@odata.bind": "/emails(d34e3955-59d6-e711-80ce-00155d016797)" } ], "RegardingType":"Microsoft.Dynamics.CRM.opportunity" }
|
{ "TemplateId":"CD512306-14D6-E711-80CE-00155D016797", "Regarding": { "@odata.type": "Microsoft.Dynamics.CRM.opportunity", "@odata.id": "e63d7331-8bcb-e711-80cd-00155d016797", "@odata.RegardingType": "Microsoft.Dynamics.CRM.opportunity" }, "@odata.RegardingType": "Microsoft.Dynamics.CRM.opportunity", "Target": { "@odata.type": "Microsoft.Dynamics.CRM.email", "@odata.id": "d34e3955-59d6-e711-80ce-00155d016797", "@odata.RegardingType": "Microsoft.Dynamics.CRM.opportunity" } }
|
{ "TemplateId":"CD512306-14D6-E711-80CE-00155D016797", "Regarding": { "@odata.type": "Microsoft.Dynamics.CRM.opportunity", "@odata.id": "e63d7331-8bcb-e711-80cd-00155d016797", "@odata.RegardingType": "Microsoft.Dynamics.CRM.opportunity" }, "Target": { "@odata.type": "Microsoft.Dynamics.CRM.email", "@odata.id": "d34e3955-59d6-e711-80ce-00155d016797", "@odata.RegardingType": "Microsoft.Dynamics.CRM.opportunity" } }
|
If I try the below (which seemed to be the most logical solution):
{ "TemplateId":"CD512306-14D6-E711-80CE-00155D016797", "Regarding": { "@odata.type": "Microsoft.Dynamics.CRM.opportunity", "@odata.id": "e63d7331-8bcb-e711-80cd-00155d016797" }, "RegardingType": "Microsoft.Dynamics.CRM.opportunity", "Target": { "@odata.type": "Microsoft.Dynamics.CRM.email", "@odata.id": "d34e3955-59d6-e711-80ce-00155d016797" } }
|
I get a different error message:
HTTP/1.1 400 Bad Request Cache-Control: no-cache Pragma: no-cache Content-Type: application/json; odata.metadata=minimal Expires: -1 Server: Microsoft-IIS/8.5 REQ_ID: 859409a7-565e-43bf-b406-1408162ff220 OData-Version: 4.0 X-AspNet-Version: 4.0.30319 Persistent-Auth: true X-Powered-By: ASP.NET Date: Fri, 01 Dec 2017 07:30:25 GMT Content-Length: 2098
{ "error":{ "code":"","message":"The parameter 'RegardingType' in the request payload is not a valid parameter for the operation 'SendEmailFromTemplate'.","innererror":{ "message":"The parameter 'RegardingType' in the request payload is not a valid parameter for the operation 'SendEmailFromTemplate'.","type":"Microsoft.Crm.CrmHttpException","stacktrace":" at Microsoft.Crm.Extensibility.OData.CrmODataUtilities.ValidateInputParameters(ModelStateDictionary controllerModelState)\r\n at Microsoft.Crm.Extensibility.OData.ActionController.PostUnboundAction(String operationName, ODataUntypedActionParameters parameters)\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.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.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.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.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()" } } }
|
Does anyone know how to make this call work?