I am trying to create Survey Activity(Invitation) using Dynamics 365 WEB AP. But It fails with below error.
To generate a survey unique code, send an individual email to each participant. System.ArgumentException: An item with the same key has already been added.\r\n at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)\r\n at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)\r\n at Microsoft.Crm.Surveys.Plugins.InvitationPlugin.CreateInvitationAddressees(Entity invitation, EntityCollection to, String invitationToMultipleRecipientsMessage, VocPluginContext vocPluginContext)".
Below is my code to generate activity.
{
"subject": "test From API",
"msdyn_surveyid@odata.bind": "/msdyn_surveys(71507798-69C3-E611-810A-3863BB34ED18)",
"regardingobjectid_contact@odata.bind": "/contacts(D92237FF-D2CC-E611-810E-3863BB355D40)",
"msdyn_surveyinvite_activity_parties": [
{
"partyid_contact@odata.bind": "/contacts(D92237FF-D2CC-E611-810E-3863BB355D40)",
"participationtypemask": 2
}
]
}
C# Code
JArray parties = new JArray();
JObject SurveyActivity = new JObject();
SurveyActivity["subject"] = "test From API";
//Set To
JObject receiver1 = new JObject();
receiver1["partyid_contact@odata.bind"] = "/contacts(D92237FF-D2CC-E611-810E-3863BB355D40)";
receiver1["participationtypemask"] = 2; //To
parties.Add(receiver1);
//JObject sender = new JObject();
//sender["partyid_systemuser@odata.bind"] = "/contacts(D92237FF-D2CC-E611-810E-3863BB355D40)";
//sender["participationtypemask"] = 1; //From
//parties.Add(sender);
SurveyActivity["msdyn_surveyid@odata.bind"] = "/msdyn_surveys(71507798-69C3-E611-810A-3863BB34ED18)";
SurveyActivity["regardingobjectid_contact@odata.bind"] = "/contacts(D92237FF-D2CC-E611-810E-3863BB355D40)";
SurveyActivity["msdyn_surveyinvite_activity_parties"] = parties;