0

I am able to create a data extension using PHP, but only in the parent account. I know how to target different folders, but I need to create the data extension in a specific Business Unit. How can that be accomplished? I have looked in the Docs and combed through the exacttarget_soap_client.php file and for the life of me, I cannot figure it out.

Thank you.

4

I can't help you specifically with PHP, but I can give you the raw SOAP wrapper, which hopefully you can use to translate to PHP.

Before we get in to the SOAP wrappers, here are some documentation links for working with accounts with multiple Business Units: https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/managing_enterprise_20_accounts_with_the_web_services_api.htm

Oh! If you're using the SDK, this page might have exactly what you need: https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/using_clientid_in_your_soap_api_code.htm

And, here's my explanation of how to specify a BU in the raw SOAP calls...

You need to set the Client ID (the Business unit MID) in your API call. In Create, Delete, Perform, and Update SOAP calls you do that like this:

    <Client>
       <ID>${#Project#BU}</ID>
    </Client>

Retrieve calls use a different format:

    <ClientIDs>
       <ClientID>1427728</ClientID>
    </ClientIDs>

Here is the Client ID (MID) inside a Create DataExtension API call, in situ:

<soapenv:Envelope xmlns:soapenv="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">
   <soapenv:Header>
      <wsse:Security soapenv:mustUnderstand="1">
         <wsse:UsernameToken>
            <wsse:Username>${#Project#username}</wsse:Username>
            <wsse:Password>${#Project#pw}</wsse:Password>
         </wsse:UsernameToken>
      </wsse:Security>
   </soapenv:Header>
   <soapenv:Body>
      <CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
         <Options/>
         <Objects xsi:type="DataExtension">
            <Client>
               <ID>${#Project#BU}</ID>
            </Client>
            <Name>DE_TriggerPauseLog</Name>
            <CustomerKey>DE_TriggerPauseLog</CustomerKey>
            <Description>A place to keep track of what triggers are purposefully in an inactive state</Description>
            <IsSendable>false</IsSendable>
            <Fields>
               <Field>
                    <Name>TSDCustomerKey</Name>
                    <MaxLength>50</MaxLength>
                    <IsRequired>true</IsRequired>
                    <Ordinal>1</Ordinal>
                    <IsPrimaryKey>true</IsPrimaryKey>
                    <FieldType>Text</FieldType>
               </Field>
               <Field>
                    <Name>Status</Name>
                    <MaxLength>20</MaxLength>
                    <IsRequired>true</IsRequired>
                    <Ordinal>2</Ordinal>
                    <IsPrimaryKey>false</IsPrimaryKey>
                    <FieldType>Text</FieldType>
               </Field>
               <Field>
                    <Name>ModifiedDate</Name>
                    <Scale>0</Scale>
                    <DefaultValue>GetDate()</DefaultValue>
                    <IsRequired>true</IsRequired>
                    <Ordinal>3</Ordinal>
                    <IsPrimaryKey>false</IsPrimaryKey>
                    <FieldType>Date</FieldType>
               </Field>
            </Fields>
         </Objects>
      </CreateRequest>
   </soapenv:Body>
</soapenv:Envelope>
  • 2
    OMG! that did it! thanks for posting this, really helped me out! From your soap envelope i was able to determine how to set it, like this $de->Client->ID = XXX; I was just doing$de->Client = XXX; and it wasn't working, but this did! – garek007 Aug 4 '18 at 0:36

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.