4.5 RuleOperationErrorType

The following is an example of an UpdateInboxRules operation that results in a validation error. This example sets the RuleId element, which specifies the rule (2) identifier. When creating a rule (2), the Rule element cannot include a RuleID element. The rule (2) identifier is generated when the rule (2) is successfully created in the server message store.

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 a RuleId 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:RuleId>dCsAAABjz0Q=</t:RuleId>
             <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:Conditions>
             <t:Exceptions />
             <t:Actions>
               <t:MoveToFolder>
                 <t:DistinguishedFolderId Id="inbox" />
               </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 information about the cause of the validation error.

 <?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="139" 
         MinorBuildNumber="0" 
         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>Validation error occurred during rule operation execution.</MessageText>
       <ResponseCode>ErrorInboxRulesValidationError</ResponseCode>
       <DescriptiveLinkKey>0</DescriptiveLinkKey>
       <RuleOperationErrors>
         <RuleOperationError xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
           <OperationIndex>0</OperationIndex>
           <ValidationErrors>
             <Error>
               <FieldURI>RuleId</FieldURI>
               <ErrorCode>CreateWithRuleId</ErrorCode>
               <ErrorMessage>Create rule operation should not have rule ID set in request.</ErrorMessage>
               <FieldValue>dCsAAABjz0Q=</FieldValue>
             </Error>
           </ValidationErrors>
         </RuleOperationError>
       </RuleOperationErrors>
     </UpdateInboxRulesResponse>
   </s:Body>
 </s:Envelope>