2

is there a way to remove a Role from a user using the Marketing Cloud SOAP API? I've retrieved the AccountUser object with the corresponding Roles, I remove the specific Role from the array and make an Update to that user and it's Roles. I get a successful response from the API but when I go check in Marketing Cloud the user still has the role I was trying to remove.

Any insights or past experience is greatly appreciated. Thanks!

1
  • Can you share teh soap enevelope you are using to update the accountuser object?
    – EazyE
    Dec 5, 2019 at 20:16

3 Answers 3

1

Use following soap request to remove role at business unit level:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
 <soap:Header>
    <wsa:Action>Configure</wsa:Action>
    <wsa:MessageID>urn:uuid:1f56f49d-3edf-4782-99ff-9889d9b88a4a</wsa:MessageID>
    <wsa:ReplyTo>
        <wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
    </wsa:ReplyTo>
    <wsa:To>https://webservice.{{stack}}.exacttarget.com/Service.asmx</wsa:To>
    <fueloauth>[ACCESS_TOKEN]</fueloauth>
</soap:Header>
<soap:Body>
    <ConfigureRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
            <Action>assign</Action>
            <Configurations>
              <Configuration xsi:type="Role">
                   <!--*****ROLE ID*****-->
                   <ObjectID>[ROLE_ID]</ObjectID>
                         <AssignmentConfigurations>
                             <AssignmentConfiguration>
                                <AccountUserId>[USER_ID]</AccountUserId>
                                <BusinessUnitId>[MID_HERE]</BusinessUnitId>
                                <AssignmentConfigureType>RoleUserBusinessUnit</AssignmentConfigureType>
                                <!--TO DELETE ROLE FROM USER AT BUSINESSUNIT MARK TRUE -->
                                <IsDelete>true</IsDelete>
                             </AssignmentConfiguration>
                          </AssignmentConfigurations>
            </Configuration>
        </Configurations>
    </ConfigureRequestMsg>
</soap:Body>

2
  • Thank you! When I perform that request I get: <OverallStatus>OK</OverallStatus> But the change is not reflected in the UI.
    – patosapir
    Dec 6, 2019 at 21:59
  • @patosapir this request is for removing roles assigned at Business Unit level and not directly assigned to the user. Please check how role was assigned. Dec 7, 2019 at 8:24
1

I've actually was able to do this based on the previous response provided, here's the SOAP body:

<soap:Body>
        <UpdateRequest
            xmlns="http://exacttarget.com/wsdl/partnerAPI">
            <Objects xsi:type="AccountUser">
                <Client>
                    <ID>[[MID]]</ID>
                </Client>
                <UserID>psapirasdasd.devsutd</UserID>
                <Roles>
                    <Role>
                        <ObjectID>[[Role.ObjectID]]</ObjectID>
                        <AssignmentConfigurations>
                            <AssignmentConfiguration>
                                <AccountUserId>[[User.ID]]</AccountUserId>
                                <AssignmentConfigureType>RoleUser</AssignmentConfigureType>
                                <IsDelete>true</IsDelete>
                            </AssignmentConfiguration>
                        </AssignmentConfigurations>
                    </Role>
                </Roles>
            </Objects>
        </UpdateRequest>
    </soap:Body>
1
  • Thanks for sharing this code, I am trying to do the opposite - assigning a custom role to a user. I can't figure out how to do it. Do you mind sharing where do you find the fields name for 'AssignmentConfiguration'?
    – Eliott
    May 23, 2020 at 15:52
-1

Use below request payload to remove/add role to the accountuser

<soap:Body>
            
            <UpdateRequest xmlns=\"http://exacttarget.com/wsdl/partnerAPI\" xmlns:ns2=\"urn:fault.partner.exacttarget.com\">
            <Objects xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"AccountUser\">
            <Client>
            <ClientID>[[ClientID]]</ClientID>
            </Client>
            <UserID>[[Accountuser.userid]]</UserID>
                   
            <Roles>

                       <Role>
                                    <ObjectID>[[ROLE.ObjectID]]</ObjectID>
            
            <AssignmentConfigurations>
            <AssignmentConfiguration>
            <AccountUserId>[[Accountuser.ID]]</AccountUserId>
            <AssignmentConfigureType>RoleUser</AssignmentConfigureType>
            <IsDelete>[[if true will be deleted/removed from user. if false assign the user.]]</IsDelete>
            </AssignmentConfiguration>
            </AssignmentConfigurations>
            
                                </Role>
                            </Roles>
            <DefaultBusinessUnit>[[BusinessunitID]]</DefaultBusinessUnit>
            </Objects></UpdateRequest>
            
                </soap:Body>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.