1

I created Test email in classic content using below code. but i need to create same email in content builder through soap api.could you please send me Sopa api code for creating email in content builder.

 <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <Header>
            <Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
                <UsernameToken>
                    <Username>user123@sfdc.com</Username>
                    <Password>xxxxx</Password>
                </UsernameToken>
            </Security>
        </Header>
        <Body>
            <CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
                <Options/>
                <Objects xsi:type="Email">
                    <ObjectID xsi:nil="true"/>
                    <Name>Text Only in API</Name>
                    <Description>Description</Description>
                    <TextBody>Good Day,

    Below are the stats from Activity.

    -   Number of new Emails
    -   Number of Old email 
    -   Number of After 10 days emailemail 

    Thank you


    </TextBody>
                <Subject>AppData Web Activity Reporting </Subject>
                    <EmailType>Text Only</EmailType>
                </Objects>
            </CreateRequest>
        </Body>
    </Envelope>
2

Unfortunately, it is not possible to create assets in content builder with the SOAP API. You must use the REST API to do this. See Content Builder API to get started

From the docs:

Marketing developers, service providers, and third-party developers can create and manipulate marketing content using the Content Builder REST API

| improve this answer | |
1

Things may have changed since Samuel answered... The SOAP API does allow to create content assets. See supported methods for objects here.

Here is a sample envelope you can use to create a simple content block via SOAP API

    <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>
        <fueloauth>{{token}}</fueloauth>
    </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">
            <Objects xsi:type="Asset">
                <ContentType>text/html</ContentType>
                <Name>soap api created content asset</Name>
                <MemberId>123</MemberId>
                <EnterpriseId>123</EnterpriseId>
                <Content>&lt;b&gt;asdasdasd&lt;/b&gt;</Content>
                <AssetType>
                    <Id>197</Id>
                    <Name>htmlblock</Name>
                    <DisplayName>HTML Block</DisplayName>
                </AssetType>
                <Status>
                    <Id>1</Id>
                    <Name>Draft</Name>
                </Status>
                <Category>
                    <Id>442</Id>
                    <Name>Content Builder</Name>
                    <ParentId>0</ParentId>
                </Category>
            </Objects>
        </CreateRequest>
    </s:Body>
</s:Envelope>

Some more notes and methods: To find out what is retrievable, you can use a Describe action on any Object and examine the response. Here is an example request for the Asset object.

POST / HTTP/1.1
Host: https://mc31kxxxxxxxxxxq0d7m.soap.marketingcloudapis.com/Service.asmx
SOAPAction: Describe
Content-Type: text/xml; charset=utf-8
Content-Type: text/plain
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header>
        <fueloauth>eyxxxxxxxsoS5SL</fueloauth>
    </soapenv:Header>
    <soapenv:Body>
          <DefinitionRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
            <DescribeRequests>
              <ObjectDefinitionRequest>
                <ObjectType>Asset</ObjectType>
              </ObjectDefinitionRequest>
            </DescribeRequests>
          </DefinitionRequestMsg>
    </soapenv:Body>
</soapenv:Envelope>

I have a short jQuery snippet you can run in any browser console to grab all the retrievable properties which you can then copy into my retrieve request. Note, you may need to remove line breaks / odd characters.

var soap = '<soap:Envelope xmlns:s.....COPY THE FULL RESPONSE HERE....</soap:Envelope>',
xmlDoc = $.parseXML( soap ),
retProps = [],
$x = $( xmlDoc );
$x
.find("IsRetrievable:contains('true')")
.closest("Properties")
.find("Name")
.each(function(){
    retProps.push(
    "<Properties>" + $(this).html() + "</Properties>"
    )
});
console.log(retProps.join(""));
//copy and paste the console message into your retrieve request
| improve this answer | |
  • This is great - However, it seems the retrieve is still very basic. I can only retrieve the ObjectID and CustomerKey but not any details about the asset itself – shd.lux May 7 at 14:49
  • @shd.lux I've updated the answer with some more details on how to get the asset content from the SOAP API – Yosef Sahler May 8 at 18:54
  • Thank you. I am aware of describe and I have used this. However, only ObjectID is IsRetrievable: true. All other informations are false. Hence, I am not able to retrieve any information of the asset. In the REST I get some information back – shd.lux May 9 at 11:18

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.