OfficeDev / ews-managed-api

Other
585 stars 321 forks source link

ExpandDL SOAP call can't expand DL with Ampersand #252

Closed naemcivic closed 4 years ago

naemcivic commented 4 years ago

Making a SOAP call to ExpadDL with a DL with an ampersand (ie: 'test&research@test.com') fails. Please help us with this issue, as many of our clients have ampersands in their DL.

SOAP call to Office.context.mailbox.makeEwsRequestAsync is as follow:

            '<m:ExpandDL>' +
            '    <m:Mailbox>' +
            '        <t:EmailAddress>' + group + '</t:EmailAddress>' +
            '    </m:Mailbox>' +
            '</m:ExpandDL>';

Result of the soap call:

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Header>
      <Action xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none" s:mustUnderstand="1">*</Action>
   </s:Header>
   <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: Unexpected end of file. Following elements are not closed: EmailAddress, Mailbox, ExpandDL, Body, Envelope. Line 1, position 513.</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>0</t:LineNumber>
               <t:LinePosition>0</t:LinePosition>
               <t:Violation>Unexpected end of file. Following elements are not closed: EmailAddress, Mailbox, ExpandDL, Body, Envelope. Line 1, position 513.</t:Violation>
            </t:MessageXml>
         </detail>
      </s:Fault>
   </s:Body>
</s:Envelope>
pjneary1 commented 4 years ago

Your group has to be encoded so "&" is rendered as "&". Just run it through HttpUtility.Encode().

naemcivic commented 4 years ago

@pjneary1 thank you for your input. escaping it does work