Search code examples
pythonexchangewebservicescontacts

Can't create Notes in Contacts exchange


I am trying to create a contact with Notes in it but instead contact gets created but I can't restore the Notes inside contact.

The dictionary key for is:"PersonalNotes". While using the below soap message, I am getting API HttpError 500 error for user. When I change the below soap message like("Hello"), my contact gets created but I can't see notes section in contact. I have also tried after changing the RequestServerVersion. I have also tried after changing the position in soap message.

<soap:Envelope
                    <t:Notes>
                        <t:Entry Key="Notes">**With Notes**</t:Entry>
                    </t:Notes>
                </t:Contact>
    </soap:Body>
</soap:Envelope>

This is soap message I am using to create the notes in contact.

response = self.client.post_retry(url='https://outlook.office365.com/EWS/Exchange.asmx', data=RestoreContact_SOAP, anchormailbox=True, content_type = 'xml')

Please Help.


Solution

  • The notes are just the body of the Item so to create them use the body property instead eg this should work

      <soap:Body>
        <CreateItem
            xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <SavedItemFolderId>
                <t:FolderId Id="AQMkADczNDE4YWEAMC03ZWZiLTQyM2QtODA1Yi02MmIyNmJkYWMyNmQALgAAA74c3T2WBidIkPPeS33fvkkBAHUQR/0Y6jBNnUCxQousINAAAAIBDgAAAA=="/>
            </SavedItemFolderId>
            <Items
                xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
                <t:Contact
                    xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
                    <FileAs>With Notes</FileAs>
                    <DisplayName>With Notes</DisplayName>
                    <GivenName>With Notes</GivenName>
                    <Initials></Initials>
                    <MiddleName></MiddleName>
                    <Nickname></Nickname>
                    <CompanyName></CompanyName>
                    <t:PhysicalAddresses>
                        <t:Entry Key="Business">
                            <t:Street></t:Street>
                            <t:City></t:City>
                            <t:State></t:State>
                            <t:CountryOrRegion></t:CountryOrRegion>
                            <t:PostalCode></t:PostalCode>
                        </t:Entry>
                        <t:Entry Key="Home">
                            <t:Street></t:Street>
                            <t:City></t:City>
                            <t:State></t:State>
                            <t:CountryOrRegion></t:CountryOrRegion>
                            <t:PostalCode></t:PostalCode>
                        </t:Entry>
                    </t:PhysicalAddresses>
                    <AssistantName></AssistantName>
                    <BusinessHomePage></BusinessHomePage>
                    <Department></Department>
                    <Generation></Generation>
                    <JobTitle></JobTitle>
                    <Manager></Manager>
                    <OfficeLocation></OfficeLocation>
                    <Profession></Profession>
                    <Surname></Surname>
                 <t:Body BodyType="Text">This is the Notes.</t:Body>
                </t:Contact>
            </Items>
        </CreateItem>
    </soap:Body>