none
CreateItem -> Contact RRS feed

  • Question

  • HI,

    I using ews to create contacts in my contact folder. Example xml code I'm using is below. Works, NoError back from server.I see the contact in Outlook after it syncs with Office 365 and I see the contact in my phone after it syncs.

    But in the Office 365 web interface the contact appears but with "Name isn't available", I can't edit the contact

    Am I putting the contact in the wrong folder?

    Anyone else experience this?

    Should I use CompleteName? If so an example xml code would be nice to see, my attempts with CompleteName failed.

    <soap:Envelope
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
     xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
     xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
      <soap:Body>
        <CreateItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" >
          <SavedItemFolderId>
            <t:DistinguishedFolderId Id="contacts"/>
          </SavedItemFolderId>
          <Items>
            <t:Contact>
              <t:FileAs>SampleContact</t:FileAs>
              <t:GivenName>Tanja</t:GivenName>
              <t:CompanyName>Blue Yonder Airlines</t:CompanyName>
              <t:EmailAddresses>
                <t:Entry Key="EmailAddress1">tplate@example.com</t:Entry>
              </t:EmailAddresses>
              <t:PhysicalAddresses>
                <t:Entry Key="Business">
                  <t:Street>1234 56th Ave</t:Street>
                  <t:City>La Habra</t:City>
                  <t:State>CA</t:State>
                </t:Entry>
              </t:PhysicalAddresses>
              <t:PhoneNumbers>
                <t:Entry Key="BusinessPhone">4255550199</t:Entry>
              </t:PhoneNumbers>
              <t:JobTitle>Manager</t:JobTitle>
              <t:Surname>Plate</t:Surname>
            </t:Contact>
          </Items>
        </CreateItem>
      </soap:Body>
    </soap:Envelope>

    Tuesday, January 21, 2014 7:27 AM

All replies

  • Hi,

    you should add the DisplayName element.

    <t:DisplayName>Plate Tanja</t:DisplayName>

    Regards,


    Désiré GOVIN, <a href="http://www.refresh-it-solutions.com"><b>Refresh IT Solutions.com</b></a>

    Tuesday, January 21, 2014 9:51 AM
  • I have actually tried that before I posted this question.

    I have tried all allowed elements inside of

    <t:Contact> but with no success to show them in Office 365.


    Tuesday, January 21, 2014 10:06 AM
  • Have you tried to set the <t:Subject> element with the same value as the display name.

    Regards,


    Désiré GOVIN Refresh IT Solutions

    Tuesday, January 21, 2014 10:15 AM
  • Just tried it and got error has invalid child element

    'faultstring' => {
                                                          'content' => 'The request failed schema validation: The element \'Items\' in namespace \'http://schemas.microsoft.com/exchange/services/2006/messages\' has invalid child element \'Subject\' in namespace \'http://schemas.microsoft.com/exchange/services/2006/types\'. List of possible elements expected: \'Item, Message, CalendarItem, Contact, DistributionList, MeetingMessage, MeetingRequest, MeetingResponse, MeetingCancellation, Task, ReplyToItem, ForwardItem, ReplyAllToItem, AcceptItem, TentativelyAcceptItem, DeclineItem, CancelCalendarItem, RemoveItem, SuppressReadReceipt\' in namespace \'http://schemas.microsoft.com/exchange/services/2006/types\'.',
                                                          'xml:lang' => 'en-US'
                                                        }

    Tuesday, January 21, 2014 10:24 AM
  • I think that you have put the <t:Subject> element out of the <t:Contact> element. It should be like this :

    <t:Contact>
      ....
      <t:Subject>my display name</t:Subject>
      ...
    </t:Contact>
    


    Regards,


    Désiré GOVIN Refresh IT Solutions

    Tuesday, January 21, 2014 10:55 AM
  • Here is a copy of the xml I sent

                       <soap:Envelope
                             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                             xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
                             xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
                              <soap:Body>
                                <CreateItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" >
                                  <SavedItemFolderId>
                                    <t:DistinguishedFolderId Id="contacts"/>
                                  </SavedItemFolderId>
                                  <Items>
                                    <t:Contact>
                                      <t:FileAs>SampleContact</t:FileAs>
                                      <t:DisplayName>Plate Tanja</t:DisplayName>                                  
                                      <t:GivenName>Tanja</t:GivenName>
                                      <t:CompanyName>Blue Yonder Airlines</t:CompanyName>
                                      <t:Subject>my display name</t:Subject>
                                      <t:EmailAddresses>
                                        <t:Entry Key="EmailAddress1">tplate@example.com</t:Entry>
                                      </t:EmailAddresses>
                                      <t:PhysicalAddresses>
                                        <t:Entry Key="Business">
                                          <t:Street>1234 56th Ave</t:Street>
                                          <t:City>La Habra</t:City>
                                          <t:State>CA</t:State>
                                          <t:CountryOrRegion>USA</t:CountryOrRegion>
                                        </t:Entry>
                                      </t:PhysicalAddresses>
                                      <t:PhoneNumbers>
                                        <t:Entry Key="BusinessPhone">4255550199</t:Entry>
                                      </t:PhoneNumbers>
                                      <t:JobTitle>Manager</t:JobTitle>
                                      <t:Surname>Plate</t:Surname>
                                    </t:Contact>
                                  </Items>
                                </CreateItem>
                              </soap:Body>
                            </soap:Envelope>

    And the error I get

    s:Fault' => {
                                         'detail' => {
                                                     't:MessageXml' => {
                                                                       't:LineNumber' => '17',
                                                                       't:LinePosition' => '18',
                                                                       't:Violation' => 'The element \'Contact\' in namespace \'http://schemas.microsoft.com/exchange/services/2006/types\' has invalid child element \'Subject\' in namespace \'http://schemas.microsoft.com/exchange/services/2006/types\'. List of possible elements expected: \'EmailAddresses, PhysicalAddresses, PhoneNumbers, AssistantName, Birthday, BusinessHomePage, Children, Companies, ContactSource, Department, Generation, ImAddresses, JobTitle, Manager, Mileage, OfficeLocation, PostalAddressIndex, Profession, SpouseName, Surname, WeddingAnniversary\' in namespace \'http://schemas.microsoft.com/exchange/services/2006/types\'.',
                                                                       'xmlns:t' => 'http://schemas.microsoft.com/exchange/services/2006/types'
                                                                     },

    Tuesday, January 21, 2014 11:00 AM
  • Can you try with following XML :

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Header>
          <t:RequestServerVersion Version="Exchange2013" />
        </soap:Header>
        <soap:Body>
          <m:CreateItem MessageDisposition="SaveOnly">
            <m:Items>
              <t:Contact>
                <t:Subject>test</t:Subject>
                <t:FileAs>test</t:FileAs>
                <t:DisplayName>test</t:DisplayName>
              </t:Contact>
            </m:Items>
          </m:CreateItem>
        </soap:Body>
    </soap:Envelope>


    Regards,


    Désiré GOVIN Refresh IT Solutions

    Tuesday, January 21, 2014 11:25 AM
  • I got ErrorInvalidServerVersion

    I changed it to <t:RequestServerVersion Version=\"Exchange2010_SP2\" />

    Then I get 'm:ResponseCode' => 'NoError',  'ResponseClass' => 'Success'

    Should I then find that test contact in my contacts? I didn't find it in outlook nor office 365.

    Tuesday, January 21, 2014 11:52 AM
  • It should (it works for me).

    What language are you using for creating contacts. If C#, have a look to EWS managed API.

    Regards,


    Désiré GOVIN Refresh IT Solutions

    Tuesday, January 21, 2014 1:25 PM
  • HI, I'm using Perl and sending the XML to the server.

    I'll experiment with the code you said works for you, hopefully I'll get that to work.

    Thanks for your help, if I get it to work I'll reply to this. Might be a day or two before I get to test.

    Tuesday, January 21, 2014 1:30 PM