Eric Legault
Eric Legault

Reputation: 5834

ErrorSchemaValidation errors setting flag on email with EWS SOAP

I keep getting ErrorSchemaValidation errors attempting to set a variety of flag types on an email using Exchange Web Services with SOAP (the UpdateItem operation). Here's an example of such an error:

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <s:Fault>
      <faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorSchemaValidation</faultcode>
      <faultstring xml:lang="en-US">The request failed schema validation: The 'PropertyTag' attribute is invalid - The value '802A' is invalid according to its datatype 'http://schemas.microsoft.com/exchange/services/2006/types:PropertyTagType' - The value '802A' is not valid according to any of the memberTypes of the union.</faultstring>
      <detail>
        <e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorSchemaValidation</e:ResponseCode>
        <e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">The request failed schema validation.</e:Message>
        <t:MessageXml xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
          <t:LineNumber>1</t:LineNumber>
          <t:LinePosition>1340</t:LinePosition>
          <t:Violation>The 'PropertyTag' attribute is invalid - The value '802A' is invalid according to its datatype 'http://schemas.microsoft.com/exchange/services/2006/types:PropertyTagType' - The value '802A' is not valid according to any of the memberTypes of the union.</t:Violation>
        </t:MessageXml>
      </detail>
    </s:Fault>
  </s:Body>
</s:Envelope>

And here was my request, as per adding a simple colored flag as per the specification: https://msdn.microsoft.com/en-us/library/ee204317(v=exchg.80).aspx:

<?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: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:Header>
    <RequestServerVersion Version="Exchange2013" xmlns="http://schemas.microsoft.com/exchange/services/2006/types"/>
  </soap:Header>
  <soap:Body>
    <m:UpdateItem MessageDisposition="SaveOnly" ConflictResolution="AlwaysOverwrite">
      <m:ItemChanges>
        <t:ItemChange>
          <t:ItemId Id="AAMkAGUzNmEzYTBmLTI1NDItNGE0My1iZDk5LWFkMDgxODI3YWNlOQBGAAAAAACK2VEhi72QSaw+u0XV7xUHBwAA/rMO2DXYS7rgpZoTIdkqABsXDgCjAAAuH/1UA8tzTYD5jbYriaIUAAIZ7oMeAAA=" />
          <t:Updates>
            <t:SetItemField>
              <t:ExtendedFieldURI PropertyTag="1095" PropertyType="Integer" />
              <t:Message>
                <t:ExtendedProperty>
                  <t:ExtendedFieldURI PropertyTag="1095" PropertyType="Integer" />
                  <t:Value>6</t:Value>
                </t:ExtendedProperty>
              </t:Message>
            </t:SetItemField>
            <t:SetItemField>
              <t:ExtendedFieldURI PropertyTag="802A" PropertyType="String"/>
              <t:Message>
                <t:ExtendedProperty>
                  <t:ExtendedFieldURI PropertyTag="802A" PropertyType="String"/>
                  <t:Value>Follow up</t:Value>
                </t:ExtendedProperty>
              </t:Message>
            </t:SetItemField>
            <t:SetItemField>
              <t:ExtendedFieldURI PropertyTag="83C0" PropertyType="Integer" />
              <t:Message>
                <t:ExtendedProperty>
                  <t:ExtendedFieldURI PropertyTag="83C0" PropertyType="Integer" />
                  <t:Value>3</t:Value>
                </t:ExtendedProperty>
              </t:Message>
            </t:SetItemField>
            <t:SetItemField>
              <t:ExtendedFieldURI PropertyTag="83CA" PropertyType="SystemTime" />
              <t:Message>
                <t:ExtendedProperty>
                  <t:ExtendedFieldURI PropertyTag="83CA" PropertyType="SystemTime" />
                  <t:Value>2016-01-17T03:56:50.972Z</t:Value>
                </t:ExtendedProperty>
              </t:Message>
            </t:SetItemField>
            <t:SetItemField>
              <t:ExtendedFieldURI PropertyTag="1090" PropertyType="Integer" />
              <t:Message>
                <t:ExtendedProperty>
                  <t:ExtendedFieldURI PropertyTag="1090" PropertyType="Integer" />
                  <t:Value>2</t:Value>
                </t:ExtendedProperty>
              </t:Message>
            </t:SetItemField>
            <t:SetItemField>
              <t:ExtendedFieldURI PropertyTag="0C17" PropertyType="Boolean" />
              <t:Message>
                <t:ExtendedProperty>
                  <t:ExtendedFieldURI PropertyTag="0C17" PropertyType="Boolean" />
                  <t:Value>True</t:Value>
                </t:ExtendedProperty>
              </t:Message>
            </t:SetItemField>
            <t:SetItemField>
              <t:ExtendedFieldURI PropertyTag="0063" PropertyType="Boolean" />
              <t:Message>
                <t:ExtendedProperty>
                  <t:ExtendedFieldURI PropertyTag="0063" PropertyType="Boolean" />
                  <t:Value>True</t:Value>
                </t:ExtendedProperty>
              </t:Message>
            </t:SetItemField>
          </t:Updates>
        </t:ItemChange>
      </m:ItemChanges>
    </m:UpdateItem>
  </soap:Body>
</soap:Envelope>

I started out setting a time flag (as per the specification: https://msdn.microsoft.com/en-us/library/ee201784(v=exchg.80).aspx) but I was getting the same schema validation error. I tried removing various properties from the request but it didn't matter - it would just error out on a different field. So I'm attempting to simplify with just a color flag as time flags are quite complex and I just want to verify that this can be done first.

What am I doing wrong?

Upvotes: 1

Views: 406

Answers (1)

Glen Scales
Glen Scales

Reputation: 22032

The properties your trying to set in the 0x8000 range are named properties and your trying to use them like tagged properties which won't work (your also missing 0x in front of your hex tag value). You need to define and use those properties like

<t:Updates>
  <t:SetItemField>
    <t:ExtendedFieldURI DistinguishedPropertySetId="Common" PropertyId="34096" PropertyType="String" />
    <t:Message>
      <t:ExtendedProperty>
        <t:ExtendedFieldURI DistinguishedPropertySetId="Common" PropertyId="34096" PropertyType="String" />
        <t:Value>Follow up</t:Value>
      </t:ExtendedProperty>
    </t:Message>
  </t:SetItemField>
  <t:SetItemField>
    <t:ExtendedFieldURI PropertyTag="4245" PropertyType="Integer" />

    <t:Message>
      <t:ExtendedProperty>
        <t:ExtendedFieldURI PropertyTag="4245" PropertyType="Integer" />
        <t:Value>6</t:Value>
      </t:ExtendedProperty>
    </t:Message>
  </t:SetItemField>
  <t:SetItemField>
    <t:ExtendedFieldURI PropertyTag="4240" PropertyType="Integer" />

    <t:Message>
      <t:ExtendedProperty>
        <t:ExtendedFieldURI PropertyTag="4240" PropertyType="Integer" />
        <t:Value>2</t:Value>
      </t:ExtendedProperty>
    </t:Message>
  </t:SetItemField>
  <t:SetItemField>
    <t:ExtendedFieldURI PropertyTag="3627" PropertyType="Integer" />

    <t:Message>
      <t:ExtendedProperty>
        <t:ExtendedFieldURI PropertyTag="3627" PropertyType="Integer" />
        <t:Value>1</t:Value>
      </t:ExtendedProperty>
    </t:Message>
  </t:SetItemField>
  <t:SetItemField>
    <t:ExtendedFieldURI DistinguishedPropertySetId="Common" PropertyId="34208" PropertyType="SystemTime" />
    <t:Message>
      <t:ExtendedProperty>
        <t:ExtendedFieldURI DistinguishedPropertySetId="Common" PropertyId="34208" PropertyType="SystemTime" />
        <t:Value>2016-01-19T12:24:28.320+11:00</t:Value>
      </t:ExtendedProperty>
    </t:Message>
  </t:SetItemField>
  <t:SetItemField>
    <t:ExtendedFieldURI DistinguishedPropertySetId="Task" PropertyId="33028" PropertyType="SystemTime" />
    <t:Message>
      <t:ExtendedProperty>
        <t:ExtendedFieldURI DistinguishedPropertySetId="Task" PropertyId="33028" PropertyType="SystemTime" />
        <t:Value>2016-01-18T12:24:28.320+11:00</t:Value>
      </t:ExtendedProperty>
    </t:Message>
  </t:SetItemField>
  <t:SetItemField>
    <t:ExtendedFieldURI DistinguishedPropertySetId="Task" PropertyId="33029" PropertyType="SystemTime" />
    <t:Message>
      <t:ExtendedProperty>
        <t:ExtendedFieldURI DistinguishedPropertySetId="Task" PropertyId="33029" PropertyType="SystemTime" />
        <t:Value>2016-01-19T12:24:28.320+11:00</t:Value>
      </t:ExtendedProperty>
    </t:Message>
  </t:SetItemField>
  <t:SetItemField>
    <t:ExtendedFieldURI DistinguishedPropertySetId="Common" PropertyId="34070" PropertyType="SystemTime" />
    <t:Message>
      <t:ExtendedProperty>
        <t:ExtendedFieldURI DistinguishedPropertySetId="Common" PropertyId="34070" PropertyType="SystemTime" />
        <t:Value>2016-01-17T13:00:00.000Z</t:Value>
      </t:ExtendedProperty>
    </t:Message>
  </t:SetItemField>
  <t:SetItemField>
    <t:ExtendedFieldURI DistinguishedPropertySetId="Common" PropertyId="34071" PropertyType="SystemTime" />
    <t:Message>
      <t:ExtendedProperty>
        <t:ExtendedFieldURI DistinguishedPropertySetId="Common" PropertyId="34071" PropertyType="SystemTime" />
        <t:Value>2016-01-17T13:00:00.000Z</t:Value>
      </t:ExtendedProperty>
    </t:Message>
  </t:SetItemField>
</t:Updates>

Also in Exchange 2013 there is a Strongly typed property for the Flags so you can set most of the time extended properties for flags that way eg

<t:Updates>
  <t:SetItemField>
    <t:FieldURI FieldURI="item:Flag" />
    <t:Message>
      <t:Flag>
        <t:FlagStatus>Flagged</t:FlagStatus>
        <t:StartDate>2016-01-18T01:37:21.626Z</t:StartDate>
        <t:DueDate>2016-01-19T01:37:21.626Z</t:DueDate>
      </t:Flag>
    </t:Message>
  </t:SetItemField>
</t:Updates>

Cheers Glen

Upvotes: 2

Related Questions