1

I am trying to create a new Business unit via API. I am only finding create new user or update an existing account. Can someone send me a sample code to create a new business unit using Account ID?

I got it to work its as i missed bu.ParentIDSpecified = true;.

Here is the sample code to create a business unit to an existing account.

BusinessUnit bu = new BusinessUnit();
bu.AccountType = AccountTypeEnum.BUSINESS_UNIT;      
bu.Name = "TestAPI";
bu.Email = "Test@businessunit.com";
bu.FromName = "Test BU";
bu.ParentID = // my account id
//This tells that create user in subaccount
ClientID clientID = new ClientID();            
clientID.ID = XXXX;
clientID.IDSpecified = true;
bu.Client = clientID;

String requestId = null;
String overAllStatus = null;
CreateResult[] results = client.Create(new CreateOptions(), new APIObject[] { bu }, out requestId, out overAllStatus);
  • 1
    Please share what you have tried. The usage of the Create method follows the same pattern for all objects so the example for AccountUser would be very similar to BusinessUnit except the properties defined on the object would be different. If you are unsure of the property names for an object, there is reference documentation at: help.marketingcloud.com/en/technical_library/web_service_guide/… – Mac Jul 7 '16 at 14:50
  • Thanks i will try it out by changing the object name to business unit and share my sample code – Deepak Jul 7 '16 at 18:36
0

Below is the SOAP Envelope for creating a Business Unit -

<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">Create</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">
  <CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
     <Options>

     </Options>
     <Objects xsi:type="BusinessUnit">
        <PartnerKey xsi:nil="true"/>
        <ObjectID xsi:nil="true"/>
        <AccountType>BUSINESS_UNIT</AccountType>
        <ParentID>{{TopLevelBU}}</ParentID>
        <OrgID>{{TopLevelBU}}</OrgID>
        <Name>Maneesh Test BU1</Name>
        <Email>xxx@xxx.com</Email>
        <FromName>Maneesh From Name</FromName>
        <BusinessName>Maneesh and Company1</BusinessName>
        <Address>123 Main St.</Address>
        <City>Indianapolis</City>
        <State>IN</State>
        <Zip>46202</Zip>
        <IsActive>1</IsActive>

        <IsTestAccount>false</IsTestAccount>
        <EditionID>3</EditionID>
        <Subscription xsi:nil="true"/>
     </Objects>
  </CreateRequest>
</s:Body>
</s:Envelope>

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.