[SalesForce] Retrieving User Details using SOAP API

I want to retrieve details of the users of our Marketing Cloud account using SOAP. Looked through the document and created the below SOAP envelop. It is working fine but does not retrieve the Associated Business Units and Roles for the users

What am I missing?

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
  <a:Action s:mustUnderstand="1">Retrieve</a:Action>
  <a:MessageID>urn:uuid:5dfca442-f1a0-4f7c-9419-8ace5658d2a3</a:MessageID>
  <a:ReplyTo>
     <a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>
  </a:ReplyTo>
  <a:To s:mustUnderstand="1">https://webservice.s6.exacttarget.com/Service.asmx</a:To>
  <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
     <o:UsernameToken u:Id="uuid-88b91f91-bac2-489b-90fb-37e7b256e20c-1">
        <o:Username>xxx</o:Username>
        <o:Password>xxx</o:Password>
     </o:UsernameToken>
  </o:Security>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
  <RetrieveRequest>

     <ObjectType>AccountUser</ObjectType>
     <QueryAllAccounts>true</QueryAllAccounts> // to enable child accounts
     <Properties>email</Properties>
     <Properties>ActiveFlag</Properties>
     <Properties>CreatedDate</Properties>
     <Properties>isAPIUser</Properties>
     <Properties>UserID</Properties>
     <Properties>LastSuccessfulLogin</Properties>
      <AssociatedBusinessUnits>
        <BusinessUnit>
     <Properties>Name</Properties>
     </BusinessUnit>
     </AssociatedBusinessUnits>
     <Roles>
        <Role>
     <Properties>Name</Properties>
     </Role>
     </Roles>

  </RetrieveRequest>
  </RetrieveRequestMsg>
</s:Body>
 </s:Envelope>

Best Answer

You'll have to do another retrieve on the BusinessUnit object after you've retrieved AccountUser. I don't think the Roles are retrievable.

Here's a sample SOAP envelope from a live API call:

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing">
   <s:Header>
      <a:Action s:mustUnderstand="1">Retrieve</a:Action>
      <a:MessageID>urn:uuid:d8aeb570-eb26-4ed3-9cf0-613df4de08b7</a:MessageID>
      <a:ReplyTo>
         <a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>
      </a:ReplyTo>
   </s:Header>
   <s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
         <RetrieveRequest>
            <ClientIDs>
               <ClientID>MID_GOES_HERE</ClientID>
               <ID>MID_GOES_HERE</ID>
            </ClientIDs>
            <ObjectType>AccountUser</ObjectType>
            <Properties>ID</Properties>
            <Properties>CreatedDate</Properties>
            <Properties>ModifiedDate</Properties>
            <Properties>Client.ID</Properties>
            <Properties>AccountUserID</Properties>
            <Properties>UserID</Properties>
            <Properties>Name</Properties>
            <Properties>Email</Properties>
            <Properties>MustChangePassword</Properties>
            <Properties>ActiveFlag</Properties>
            <Properties>ChallengePhrase</Properties>
            <Properties>ChallengeAnswer</Properties>
            <Properties>IsAPIUser</Properties>
            <Properties>NotificationEmailAddress</Properties>
            <Properties>Client.PartnerClientKey</Properties>
            <Properties>Password</Properties>
            <Properties>Locale.LocaleCode</Properties>
            <Properties>TimeZone.ID</Properties>
            <Properties>TimeZone.Name</Properties>
            <Properties>CustomerKey</Properties>
            <Properties>DefaultBusinessUnit</Properties>
            <Properties>LanguageLocale.LocaleCode</Properties>
            <Properties>Client.ModifiedBy</Properties>
            <QueryAllAccounts>true</QueryAllAccounts>
         </RetrieveRequest>
      </RetrieveRequestMsg>
   </s:Body>
</s:Envelope>
Related Topic