none
[E2007] [EWS] [C#] Internal Server Error on Item.Update() RRS feed

  • Question

  • I'm using the EWS API in C# with an onsite Exchange 2007 SP1 Server. I'm using the following code to tag a message using a custom property definition. 

    //Bind to the message in question, which works fine. 
    Item m = Item.Bind(service, new ItemId(itemid));
    
    //Define the extended property definition. 
    ExtendedPropertyDefinition def = new ExtendedPropertyDefinition(MyGUID, "my-tag-name" MapiPropertyType.String);
    
    //Set the extended property to our tag which is a string 
    m.SetExtendedProperty(def, tag);
    
    //Starting tracing, see XML snippet below. 
    service.TraceEnabled = true; 
    
    //Update the message with our new tag.                 
    i.Update(ConflictResolutionMode.AlwaysOverwrite);
    
    

    The issue is the server is throwing "Internal Server Errors' in response as shown in the trace below. Its not a general issue with credentials/autodiscover as I'm able to bind to messages and retrieve information about them without an issue. 

    Does anyone have any ideas? 

    <Trace Tag="EwsRequestHttpHeaders" Tid="1" Time="2014-03-03 12:52:49Z">
    POST /EWS/Exchange.asmx HTTP/1.1
    Content-Type: text/xml; charset=utf-8
    Accept: text/xml
    User-Agent: ExchangeServicesClient/15.00.0516.014
    Accept-Encoding: gzip,deflate
    
    
    </Trace>
    <Trace Tag="EwsRequest" Tid="1" Time="2014-03-03 12:52:49Z" Version="15.00.0516.
    014">
      <?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://sc
    hemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xml
    soap.org/soap/envelope/">
        <soap:Header>
          <t:RequestServerVersion Version="Exchange2007_SP1" />
          <t:TimeZoneContext>
            <t:TimeZoneDefinition Id="GMT Standard Time" />
          </t:TimeZoneContext>
        </soap:Header>
        <soap:Body>
          <m:UpdateItem MessageDisposition="SaveOnly" ConflictResolution="AlwaysOver
    write">
            <m:ItemChanges>
              <t:ItemChange>
                <t:ItemId Id="<<Removed>>=" ChangeKey="<<Removed>>" />
                <t:Updates>
                  <t:SetItemField>
                    <t:ExtendedFieldURI PropertySetId="2b3c76fb-2ea6-4644-a9d1-ae5b5
    8b4396b" PropertyName="mytag" PropertyType="String" />
                    <t:Message>
                      <t:ExtendedProperty>
                        <t:ExtendedFieldURI PropertySetId="2b3c76fb-2ea6-4644-a9d1-a
    e5b58b4396b" PropertyName="mytag" PropertyType="String" />
                        <t:Value>tagvalue</t:Value>
                      </t:ExtendedProperty>
                    </t:Message>
                  </t:SetItemField>
                </t:Updates>
              </t:ItemChange>
            </m:ItemChanges>
          </m:UpdateItem>
        </soap:Body>
      </soap:Envelope>
    </Trace>
    <Trace Tag="EwsResponseHttpHeaders" Tid="1" Time="2014-03-03 12:52:49Z">
    HTTP/1.1 200 OK
    Content-Encoding: gzip
    Vary: Accept-Encoding
    Content-Length: 551
    Cache-Control: private, max-age=0
    Content-Type: text/xml; charset=utf-8
    Date: Mon, 03 Mar 2014 12:52:49 GMT
    Server: Microsoft-IIS/7.0
    X-AspNet-Version: 2.0.50727
    X-Powered-By: ASP.NET
    
    
    </Trace>
    <Trace Tag="EwsResponse" Tid="1" Time="2014-03-03 12:52:49Z" Version="15.00.0516
    .014">
      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs
    i="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/
    XMLSchema">
        <soap:Header>
          <t:ServerVersionInfo MajorVersion="8" MinorVersion="1" MajorBuildNumber="4
    36" MinorBuildNumber="0" Version="Exchange2007_SP1" xmlns:t="http://schemas.micr
    osoft.com/exchange/services/2006/types" />
        </soap:Header>
        <soap:Body>
          <m:UpdateItemResponse xmlns:t="http://schemas.microsoft.com/exchange/servi
    ces/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/mes
    sages">
            <m:ResponseMessages>
              <m:UpdateItemResponseMessage ResponseClass="Error">
                <m:MessageText>An internal server error occurred. The operation fail
    ed.</m:MessageText>
                <m:ResponseCode>ErrorInternalServerError</m:ResponseCode>
                <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
                <m:Items />
              </m:UpdateItemResponseMessage>
            </m:ResponseMessages>
          </m:UpdateItemResponse>
        </soap:Body>
      </soap:Envelope>
    </Trace>


    Monday, March 3, 2014 1:40 PM

All replies

  • I would suggest rather then specifying your own GUID you just use the PublicStrings Guid from the DefaultExtendedPropertySet and that should work okay eg

                //Define the extended property definition. 
                ExtendedPropertyDefinition def = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "my-tag-name", MapiPropertyType.String);
    
                //Set the extended property to our tag which is a string 
                m.SetExtendedProperty(def, tag);

    It looks like your server is only running SP1 RU4 so you are a fair way behind on patches so you might want to look at updating.

    Cheers
    Glen

    Tuesday, March 4, 2014 3:28 AM
  • Thanks Glen, 

    I've was previously using the Public Strings Default property set, but it returns the same error. 

    The code works fine against an exchange online account, but I'm not sure how to go about debugging the internal server error. I've tried turning on detailed error logs in IIS but it doesn't seem to generate anything for these requests. 

    Tuesday, March 4, 2014 9:23 AM
  • Can you update other properties ? Can you set the properties on Create ?

    Given that patch level of Exchange your server is running at I would say your first action should be to upgrade to latest service pack and rollup so you have a supportable installation (SP1 rollup 4 was released in October 2008).

    The only other suggestion would be to turn up the diagnostic logging in Exchange

    Cheers
    Glen

    Wednesday, March 5, 2014 9:27 AM