Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

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

Posted on by Microsoft Employee

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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans