web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

"Cannot insert duplicate key" where try to create appointment with SOAP

(0) ShareShare
ReportReport
Posted on by

Hi all,

I'm trying to create some appointments with the api SOAP but I have a big problem. When i try to fill the field "Mandatory Participants" (requiredattendees), I can create the appointment. But If I try to create another appointment with the same data in Mandatory Participants, I received a SOAP error message : IOrganizationServiceCreateOrganizationServiceFaultFaultFaultMessage: Cannot insert duplicate key

There is my SOAP : 

<?xml version="1.0" encoding="UTF-8"?>

<soap:Envelope xmlns:soap="schemas.xmlsoap.org/.../envelope">
   <soap:Body>
      <ns3:Create xmlns:ns3="schemas.microsoft.com/.../Services" xmlns="schemas.datacontract.org/.../System.Collections.Generic" xmlns:ns10="schemas.datacontract.org/.../Microsoft.Crm.Sdk.Messages" xmlns:ns11="schemas.microsoft.com/.../Contracts" xmlns:ns12="schemas.microsoft.com/.../Serialization" xmlns:ns2="schemas.microsoft.com/.../Contracts" xmlns:ns4="schemas.microsoft.com/.../Arrays" xmlns:ns5="schemas.microsoft.com/.../Query" xmlns:ns6="schemas.datacontract.org/.../Microsoft.Xrm.Sdk" xmlns:ns7="schemas.microsoft.com/.../Metadata" xmlns:ns8="schemas.microsoft.com/.../Metadata" xmlns:ns9="schemas.microsoft.com/.../Contracts">
         <ns3:entity>
            <ns2:Attributes>
               <ns2:KeyValuePairOfstringanyType>
                  <key>subject</key>
                  <value xmlns:xs="www.w3.org/.../XMLSchema" xmlns:xsi="www.w3.org/.../XMLSchema-instance" xsi:type="xs:string">Test Participant</value>
               </ns2:KeyValuePairOfstringanyType>
               <ns2:KeyValuePairOfstringanyType>
                  <key>regardingobjectid</key>
                  <value xmlns:xsi="www.w3.org/.../XMLSchema-instance" xsi:type="ns2:EntityReference">
                     <ns2:Id>f54b8de4-988c-e711-98c9-005056921cd7</ns2:Id>
                     <ns2:LogicalName>account</ns2:LogicalName>
                     <ns2:Name xsi:nil="true" />
                  </value>
               </ns2:KeyValuePairOfstringanyType>
               <ns2:KeyValuePairOfstringanyType>
                  <key>ownerid</key>
                  <value xmlns:xsi="www.w3.org/.../XMLSchema-instance" xsi:type="ns2:EntityReference">
                     <ns2:Id>30153d17-9a6b-e711-b12b-005056921cd7</ns2:Id>
                     <ns2:LogicalName>systemuser</ns2:LogicalName>
                     <ns2:Name xsi:nil="true" />
                  </value>
               </ns2:KeyValuePairOfstringanyType>
               <ns2:KeyValuePairOfstringanyType>
                  <key>scheduledstart</key>
                  <value xmlns:xs="www.w3.org/.../XMLSchema" xmlns:xsi="www.w3.org/.../XMLSchema-instance" xsi:type="xs:dateTime">2018-01-20T12:50:00+01:00</value>
               </ns2:KeyValuePairOfstringanyType>
               <ns2:KeyValuePairOfstringanyType>
                  <key>scheduledend</key>
                  <value xmlns:xs="www.w3.org/.../XMLSchema" xmlns:xsi="www.w3.org/.../XMLSchema-instance" xsi:type="xs:dateTime">2018-01-20T13:50:00+01:00</value>
               </ns2:KeyValuePairOfstringanyType>
               <ns2:KeyValuePairOfstringanyType>
                  <key>requiredattendees</key>
                  <value xmlns:xsi="www.w3.org/.../XMLSchema-instance" xsi:type="ns2:EntityCollection">
                     <ns2:Entities>
                        <ns2:Entity>
                           <ns2:Attributes>
                              <ns2:KeyValuePairOfstringanyType>
                                 <key>partyid</key>
                                 <value xsi:type="ns2:EntityReference">
                                    <ns2:Id>3badb252-a109-df11-a66a-001a6409f7c2</ns2:Id>
                                    <ns2:LogicalName>contact</ns2:LogicalName>
                                    <ns2:Name xsi:nil="true" />
                                 </value>
                              </ns2:KeyValuePairOfstringanyType>
                           </ns2:Attributes>
                           <ns2:EntityState xsi:nil="true" />
                           <ns2:FormattedValues xsi:nil="true" />
                           <ns2:Id>3badb252-a109-df11-a66a-001a6409f7c2</ns2:Id>
                           <ns2:LogicalName>activityparty</ns2:LogicalName>
                           <ns2:RelatedEntities xsi:nil="true" />
                        </ns2:Entity>
                        <ns2:Entity>
                           <ns2:Attributes>
                              <ns2:KeyValuePairOfstringanyType>
                                 <key>partyid</key>
                                 <value xsi:type="ns2:EntityReference">
                                    <ns2:Id>B279B21C-1BFD-E711-BF33-005056921CD7</ns2:Id>
                                    <ns2:LogicalName>account</ns2:LogicalName>
                                    <ns2:Name xsi:nil="true" />
                                 </value>
                              </ns2:KeyValuePairOfstringanyType>
                           </ns2:Attributes>
                           <ns2:EntityState xsi:nil="true" />
                           <ns2:FormattedValues xsi:nil="true" />
                           <ns2:Id>B279B21C-1BFD-E711-BF33-005056921CD7</ns2:Id>
                           <ns2:LogicalName>activityparty</ns2:LogicalName>
                           <ns2:RelatedEntities xsi:nil="true" />
                        </ns2:Entity>
                     </ns2:Entities>
                     <ns2:EntityName>activityparty</ns2:EntityName>
                     <ns2:MinActiveRowVersion xsi:nil="true" />
                     <ns2:PagingCookie xsi:nil="true" />
                  </value>
               </ns2:KeyValuePairOfstringanyType>
            </ns2:Attributes>
            <ns2:EntityState xmlns:xsi="www.w3.org/.../XMLSchema-instance" xsi:nil="true" />
            <ns2:FormattedValues xmlns:xsi="www.w3.org/.../XMLSchema-instance" xsi:nil="true" />
            <ns2:LogicalName>appointment</ns2:LogicalName>
            <ns2:RelatedEntities xmlns:xsi="www.w3.org/.../XMLSchema-instance" xsi:nil="true" />
         </ns3:entity>
      </ns3:Create>
   </soap:Body>
</soap:Envelope>


 

Anybody have an idea?

 

Thanks!

*This post is locked for comments

I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans