4.6 RuleValidationErrorType

The following is an example of an UpdateInboxRules operation that results in a validation error. This example creates a Rule element, which specifies a MaximumSize of 9999990, which is fails validation.

The client constructs the request XML and sends it to the server. The CreateRuleOperation complex type contains the Rule complex type to be created. This example defines an improper Rule element, which causes the error.

 <?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="Exchange2010_SP1" />
   </soap:Header>
   <soap:Body>
     <m:UpdateInboxRules>
       <m:RemoveOutlookRuleBlob>true</m:RemoveOutlookRuleBlob>
       <m:Operations>
         <t:CreateRuleOperation>
           <t:Rule>
             <t:DisplayName>MoveInterestingToJunk</t:DisplayName>
             <t:Priority>1</t:Priority>
             <t:IsEnabled>true</t:IsEnabled>
             <t:IsInError>false</t:IsInError>
             <t:Conditions>
               <t:ContainsSubjectStrings>
                 <t:String>Interesting</t:String>
               </t:ContainsSubjectStrings>
               <t:WithinDateRange>
                 <t:StartDateTime>2011-04-26T18:05:13Z</t:StartDateTime>
                 <t:EndDateTime>2011-04-26T20:05:13Z</t:EndDateTime>
               </t:WithinDateRange>
               <t:WithinSizeRange>
                 <t:MinimumSize>0</t:MinimumSize>
                 <t:MaximumSize>9999990</t:MaximumSize>
               </t:WithinSizeRange>
             </t:Conditions>
             <t:Exceptions />
             <t:Actions>
               <t:MoveToFolder>
                 <t:DistinguishedFolderId Id="junkemail" />
               </t:MoveToFolder>
             </t:Actions>
           </t:Rule>
         </t:CreateRuleOperation>
       </m:Operations>
     </m:UpdateInboxRules>
   </soap:Body>
 </soap:Envelope>

The server constructs the response XML and sends it to the client. The RuleValidationError complex type contains the Error information about the cause of the validation error. In this example, the FieldValue of 9999990 and has an ErrorCode stating that this is InvalidValue.

 <?xml version="1.0" encoding="utf-8"?>
 <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Header>
     <h:ServerVersionInfo MajorVersion="14" MinorVersion="1" MajorBuildNumber="225" MinorBuildNumber="42" Version="Exchange2010_SP1" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
   </s:Header>
   <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
     <UpdateInboxRulesResponse ResponseClass="Error" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
       <MessageText>A validation error occurred while executing the rule operation.</MessageText>
       <ResponseCode>ErrorInboxRulesValidationError</ResponseCode>
       <DescriptiveLinkKey>0</DescriptiveLinkKey>
       <RuleOperationErrors>
         <RuleOperationError xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
           <OperationIndex>0</OperationIndex>
           <ValidationErrors>
             <Error>
               <FieldURI>Condition:WithinSizeRange</FieldURI>
               <ErrorCode>InvalidValue</ErrorCode>
               <ErrorMessage>The value isn't valid.</ErrorMessage>
               <FieldValue>9999990</FieldValue>
             </Error>
           </ValidationErrors>
         </RuleOperationError>
       </RuleOperationErrors>
     </UpdateInboxRulesResponse>
   </s:Body>
 </s:Envelope>
Show: