locked
Exchange EWS API: Findfolder, GetFolder and CreateFolder working finebut when I use CreateItem I just get back 500 Internal Error: Please help anyone RRS feed

  • Question

  • Hey Guys,

    I was wondering if any one could help me. Pulling my hair out here. So I have Exchange 2013. A couple of mailboxes setup, users can send mail to each other no problem and they can also login to their Outlook Web Access as well and send and receive.

    I'm using the Exchange Web Services (EWS) API to create a Folder up on someone's mailbox and then create an item inside it.

    So 

    • first I call the EWS Operation GetFolder and FindFolder to check if the particular folder already exists. This works perfectly fine.

    • Next I call the EWS Operation CreateFolder to create the folder. Again, SOAP response from Exchange is success and you can see in the users Outlook client that the folder has indeed been created. Everything working perfectly to here.

    • Then I call the EWS CreateItem operation (email message) to create an item within this folder. I pass the correct folderId but all I receive from Exchange is

    "Error 500 : Internal Server Error and thats it."

    Does anyone have any idea from what's on here. I can if required paste in the SOAP requests and responses but there are very simple standard call to these few functions. FindFolder, GetFolder and CreateFolder are fine but it all goes belly up with CreateItem and I just have no idea whats going on.

    Is there something wrong with the Exchange Server, mis - configuration, a service not running I don't know about. Completely lose.

    Much appreciated if any one could shed light on this

    Thanks

    MM

    Thursday, October 23, 2014 11:51 AM

All replies

  • Can you create Items in other folders ? eg does the same createItem request work if you specify the Inbox folder ? That error generally indicates problems with the request itself especially if your using Raw SOAP.

    When you create the Folder are you setting the FolderClass ? You generally always want to make sure you set it to IPF.Note else that can cause issues with Outlook.

    Have you had a look at the permissions that get inherited by the folder.

    Check the EWSLog on the CAS server to see if it has more information about what went wrong.

    Cheers
    Glen

    Friday, October 24, 2014 6:53 AM
  • Hey Glen,

    Thanks for the information. Going to check out what you have asked and get back to you

    Much apprepicated

    MM

    Friday, October 24, 2014 10:05 AM
  • Hi Glen,

    I tried create item with Inbox folder and got same error.

    Folder permissions is something that I’ve considered myself but having createitem failing with Inbox which is a built in folder made me think that in not the lack of permissions the reason for failure

    Any insights

    Gary

    Friday, October 24, 2014 12:23 PM
  • If it fails in the Inbox then its your CreateItem request that's invalid can you post the request that your trying to use ?

    Cheers
    Glen

    Friday, October 24, 2014 10:09 PM
  • Glen,

    Sorry for the delay but I was away. Here's the request. Copy this from fiddler, see what was exact been sent on the wire. Thanks for the help on this.

    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:ns4="http://schemas.microsoft.com/exchange/2010/Autodiscover">
    	<SOAP-ENV:Header><ns2:RequestServerVersion SOAP-ENV:mustUnderstand="1" Version="Exchange2010"></ns2:RequestServerVersion></SOAP-ENV:Header>
    
    <SOAP-ENV:Body>
    	<ns1:CreateItem xsi:type="ns1:CreateItemType" MessageDisposition="SaveOnly">
    		<ns1:SavedItemFolderId>
    			<ns2:FolderId Id="AAMkAGJlYzQwYjNkLWEwNmYtNGM5My1iYzg3LWE3MzNlZWI3YTVjOAAuAAAAAACF0APHEZwMTJgpv62BmdMLAQAlspsz1IjHSoXk2R5WkVIoAAACUhJsAAA=" xsi:type="ns2:FolderIdType"></ns2:FolderId>
    		</ns1:SavedItemFolderId>
    		<ns1:Items>
    			<ns2:Message xsi:type="ns2:MessageType">
    				
    				<ns2:ItemClass>IPM.Note.Microsoft.Conversation</ns2:ItemClass>
    				
    				<ns2:Subject>Chat with</ns2:Subject>
    				
    				<ns2:Body BodyType="HTML">&lt;!DOCTYPE html&gt;&#xA;&lt;html&gt;&lt;head&gt;&lt;title&gt;Chat&lt;/title&gt;&lt;meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/&gt;&lt;base target="_self"/&gt;&lt;style type="text/css"&gt;body{font-family: Segoe UI;font-size: 9pt;} .messageTable{width: 500px;} .buddyName{padding-top: 3px;padding-right: 0px;padding-bottom: 3px;padding-left: 8px;font-weight: bold;word-wrap: break-word;} .timeStamp{white-space: nowrap;color: #AAAAAA;font-weight: normal;vertical-align: top;padding-right: 11px;padding-left: 11px;} .dateRollover{padding-top: 3px;padding-right: 0px;padding-bottom: 3px;padding-left: 8px;font-weight: bold;word-wrap: break-word;vertical-align: middle;text-align: center;color: #1E2126;} .hiddenRow td{height: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;} .partyMsgText{color: #808080;font-style: italic;font-size: 10pt;}&lt;/style&gt;&lt;/head&gt;&lt;html&gt;&#xA; &lt;body&gt;&#xA;  &lt;table id="messageTable" class="messageTable"&gt;&#xA;   &lt;colgroup&gt;&#xA;    &lt;col/&gt;&#xA;    &lt;col id="timeStampCol" width="50px"/&gt;&#xA;   &lt;/colgroup&gt;&#xA;&lt;tr class="dividerLine" id="msg_id_13_dividerLine"&gt;&lt;td id="msg_id_13" colspan="2"/&gt;&lt;/tr&gt;&lt;tr class="groupName"&gt;&lt;td id="msg_id_13" class="buddyName" style="color:#16884f"&gt;Jim Carrey&lt;/td&gt;&lt;td class="timeStamp"/&gt;&lt;/tr&gt;&lt;tr class="msg"&gt;&lt;td id="msg_id_12" class="msgText normalMsgText"&gt;&lt;span style="font-family:Segoe UI;color:#1a1a1a;font-size:10pt;font-weight:normal;font-style:normal;text-decoration:none;"&gt;&lt;div&gt;dfgdfgfgfd&lt;/div&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class="timeStamp" title="30 October 2014"&gt;14:10&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#xA; &lt;/body&gt;&#xA;&lt;/html&gt;&#xA;</ns2:Body>
    				
    				<ns2:ExtendedProperty>
    					<ns2:ExtendedFieldURI PropertyType="Integer" PropertyName="Direction.{2DA4DF04-920D-4b0b-A1D7-5FC9D21857FE}" DistinguishedPropertySetId="PublicStrings" xsi:type="ns2:PathToExtendedFieldType"></ns2:ExtendedFieldURI>
    					<ns2:Value>1</ns2:Value>
    				</ns2:ExtendedProperty>
    				
    				<ns2:ExtendedProperty>
    					<ns2:ExtendedFieldURI PropertyType="Integer" PropertyName="Modalities.{0885EA21-B7A5-4050-BFDB-AD46DE1D6A87}" DistinguishedPropertySetId="PublicStrings" xsi:type="ns2:PathToExtendedFieldType"></ns2:ExtendedFieldURI>
    					<ns2:Value>1</ns2:Value>
    				</ns2:ExtendedProperty>
    				
    				<ns2:ExtendedProperty>
    					<ns2:ExtendedFieldURI PropertyType="Integer" PropertyName="IsCustomSubject.{703DC3CB-8F24-4e3f-932F-206233656759}" DistinguishedPropertySetId="PublicStrings" xsi:type="ns2:PathToExtendedFieldType"></ns2:ExtendedFieldURI>
    					<ns2:Value>0</ns2:Value>
    				</ns2:ExtendedProperty>
    				
    				<ns2:ExtendedProperty>
    					<ns2:ExtendedFieldURI PropertyType="String" PropertyName="DisplayDirection.{4255C773-497E-4b5e-9205-F360CAF3316A}" DistinguishedPropertySetId="PublicStrings" xsi:type="ns2:PathToExtendedFieldType"></ns2:ExtendedFieldURI>
    					<ns2:Value>Outgoing</ns2:Value>
    				</ns2:ExtendedProperty>
    				
    				<ns2:ExtendedProperty>
    					<ns2:ExtendedFieldURI PropertyType="String" PropertyName="ConversationXml.{CA2F170A-A22B-4f0a-B899-93439DEC3FBC}" DistinguishedPropertySetId="PublicStrings" xsi:type="ns2:PathToExtendedFieldType"></ns2:ExtendedFieldURI>
    					<ns2:Value>&lt;conversationsxmlns="http://schemas.microsoft.com/2008/10/sip/convItems"minSupportedClientVersion="3.0.0.0"&gt;&lt;conversationXml&gt;&lt;/conversationXml&gt;&lt;/conversations&gt;</ns2:Value>
    				</ns2:ExtendedProperty>
    				
    				<ns2:ExtendedProperty>
    					<ns2:ExtendedFieldURI PropertyTag="0x0E07" PropertyType="Integer" xsi:type="ns2:PathToExtendedFieldType"></ns2:ExtendedFieldURI>
    					<ns2:Value>1</ns2:Value>
    				</ns2:ExtendedProperty>
    				
    				<ns2:ToRecipients>
    					<ns2:Mailbox xsi:type="ns2:EmailAddressType">
    						<ns2:EmailAddress>hsimpson@sustaining.net</ns2:EmailAddress>
    					</ns2:Mailbox>
    					
    					<ns2:Mailbox xsi:type="ns2:EmailAddressType">
    						<ns2:EmailAddress>jcarrey@sustaining.net</ns2:EmailAddress>
    					</ns2:Mailbox>
    				</ns2:ToRecipients>
    				
    				<ns2:From>
    					<ns2:Mailbox xsi:type="ns2:EmailAddressType">
    						<ns2:EmailAddress>hsimpson@sustaining.net</ns2:EmailAddress>
    					</ns2:Mailbox>
    				</ns2:From>
    				
    				<ns2:IsRead>true</ns2:IsRead>
    			</ns2:Message>
    		</ns1:Items>
    	</ns1:CreateItem>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>


    • Edited by MichelleMM Thursday, October 30, 2014 2:42 PM
    Thursday, October 30, 2014 2:41 PM
  • I get the same error with your request I can't see the error but your XML isn't correct (that maybe due to whatever your using to produce it).

    Here a request that does work for me

    <?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:SavedItemFolderId>
            <t:FolderId Id="AAMkADk0OTQ3NjhhLTUzM2UtNDliMi1iYzM4LWQ5Y2JhMmMyYTkxZgAuAAAAAABpy48RairITJtRzpjfXjnTAQAOv8A6wS4pSZxXkD7GUo9PAAAAiYaNAAA="/>
          </m:SavedItemFolderId>
          <m:Items>
            <t:Message>
              <t:ItemClass>IPM.Note.Microsoft.Conversation</t:ItemClass>
              <t:Subject>Conversation with Blah Blah</t:Subject>
              <t:Body BodyType="HTML">&lt;!DOCTYPE html&gt;&#xA;&lt;html&gt;&lt;head&gt;&lt;title&gt;Chat&lt;/title&gt;&lt;meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/&gt;&lt;base target="_self"/&gt;&lt;style type="text/css"&gt;body{font-family: Segoe UI;font-size: 9pt;} .messageTable{width: 500px;} .buddyName{padding-top: 3px;padding-right: 0px;padding-bottom: 3px;padding-left: 8px;font-weight: bold;word-wrap: break-word;} .timeStamp{white-space: nowrap;color: #AAAAAA;font-weight: normal;vertical-align: top;padding-right: 11px;padding-left: 11px;} .dateRollover{padding-top: 3px;padding-right: 0px;padding-bottom: 3px;padding-left: 8px;font-weight: bold;word-wrap: break-word;vertical-align: middle;text-align: center;color: #1E2126;} .hiddenRow td{height: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;} .partyMsgText{color: #808080;font-style: italic;font-size: 10pt;}&lt;/style&gt;&lt;/head&gt;&lt;html&gt;&#xA; &lt;body&gt;&#xA;  &lt;table id="messageTable" class="messageTable"&gt;&#xA;   &lt;colgroup&gt;&#xA;    &lt;col/&gt;&#xA;    &lt;col id="timeStampCol" width="50px"/&gt;&#xA;   &lt;/colgroup&gt;&#xA;&lt;tr class="dividerLine" id="msg_id_13_dividerLine"&gt;&lt;td id="msg_id_13" colspan="2"/&gt;&lt;/tr&gt;&lt;tr class="groupName"&gt;&lt;td id="msg_id_13" class="buddyName" style="color:#16884f"&gt;Jim Carrey&lt;/td&gt;&lt;td class="timeStamp"/&gt;&lt;/tr&gt;&lt;tr class="msg"&gt;&lt;td id="msg_id_12" class="msgText normalMsgText"&gt;&lt;span style="font-family:Segoe UI;color:#1a1a1a;font-size:10pt;font-weight:normal;font-style:normal;text-decoration:none;"&gt;&lt;div&gt;dfgdfgfgfd&lt;/div&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class="timeStamp" title="30 October 2014"&gt;14:10&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#xA; &lt;/body&gt;&#xA;&lt;/html&gt;&#xA;</t:Body>
              <t:ExtendedProperty>
                <t:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="ConversationXml.{CA2F170A-A22B-4f0a-B899-93439DEC3FBC}" PropertyType="String" />
                <t:Value>&lt;conversationsxmlns="http://schemas.microsoft.com/2008/10/sip/convItems"minSupportedClientVersion="3.0.0.0"&gt;&lt;conversationXml&gt;&lt;/conversationXml&gt;&lt;/conversations&gt;</t:Value>
              </t:ExtendedProperty>
              <t:ExtendedProperty>
                <t:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="Direction.{2DA4DF04-920D-4b0b-A1D7-5FC9D21857FE}" PropertyType="Integer" />
                <t:Value>1</t:Value>
              </t:ExtendedProperty>
              <t:ExtendedProperty>
                <t:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="Modalities.{0885EA21-B7A5-4050-BFDB-AD46DE1D6A87}" PropertyType="Integer" />
                <t:Value>1</t:Value>
              </t:ExtendedProperty>
              <t:ExtendedProperty>
                <t:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="IsCustomSubject.{703DC3CB-8F24-4e3f-932F-206233656759}" PropertyType="Integer" />
                <t:Value>0</t:Value>
              </t:ExtendedProperty>
              <t:ExtendedProperty>
                <t:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="DisplayDirection.{4255C773-497E-4b5e-9205-F360CAF3316A}" PropertyType="String" />
                <t:Value>Incoming</t:Value>
              </t:ExtendedProperty>
              <t:ExtendedProperty>
                <t:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="RemoteParty.{664AD731-19D0-4344-93FD-682FE0440D95}" PropertyType="String" />
                <t:Value>sip:user2@domain.com</t:Value>
              </t:ExtendedProperty>
              <t:ExtendedProperty>
                <t:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="HistoryInfo.{553F3F08-FC28-41db-859E-63457407F806}" PropertyType="String" />
                <t:Value>sip:user2@domain.com</t:Value>
              </t:ExtendedProperty>
              <t:ExtendedProperty>
                <t:ExtendedFieldURI PropertyTag="3591" PropertyType="Integer" />
                <t:Value>1</t:Value>
              </t:ExtendedProperty>
              <t:ToRecipients>
                <t:Mailbox>
                  <t:EmailAddress>user1@domain.com</t:EmailAddress>
                </t:Mailbox>
                <t:Mailbox>
                  <t:EmailAddress>user2@domain.com</t:EmailAddress>
                </t:Mailbox>
              </t:ToRecipients>
              <t:From>
                <t:Mailbox>
                  <t:Name> Test</t:Name>
                  <t:EmailAddress>user2@domain.com</t:EmailAddress>
                </t:Mailbox>
              </t:From>
             <t:IsRead>true</t:IsRead>
            </t:Message>
          </m:Items>
        </m:CreateItem>
      </soap:Body>
    </soap:Envelope>
    Cheers
    Glen
    Friday, October 31, 2014 6:26 AM

  • The failure was due to some of those xsi:type="ns:xxxxx". Have removed all of them an everything works like a charm now.

    Thank you for your help.

    Friday, October 31, 2014 6:26 PM