0

I haven't been having luck with using the FuelSDKs to use the Marketing Cloud APIs. So I've been trying to test the SOAP API directly in postman first to see if it works; and sadly I haven't gotten that to work either...

I pretty much copied and pasted the SOAP request from here but it doesn't work. I get a 400 Bad Request

Details

First I get an access token by authenticating against https://domain.auth.marketingcloudapis.com/v2/token/

{
"grant_type": "client_credentials",
"client_id": "clientid",
"client_secret": "secret",
"scope": "data_extensions_read data_extensions_write"
}

This seems to work fine, I get the access token, which I use in the following request, which I copied verbatim from the link above.

I send the request to https://domain.soap.marketingcloudapis.com/Service.asmx

<?xml version="1.0"?>
<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:header>
  <fueloauth>
    access_token
  </fueloauth>
</s:header>
<s:body>
    <CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <Options></Options>
        <Objects xmlns:ns1="http://exacttarget.com/wsdl/partnerAPI" xsi:type="ns1:DataExtension">
            <CustomerKey>DataExtensionFromAPI</CustomerKey>
            <Name>DataExtensionFromAPI</Name>
            <IsSendable>false</IsSendable>
            <SendableDataExtensionField>
                <CustomerKey>EmailAddress_Key</CustomerKey>
                <Name>EmailAddress</Name>
                <FieldType>EmailAddress</FieldType>
            </SendableDataExtensionField>
            <SendableSubscriberField>
                <Name>Email Address</Name>
                <Value></Value>
            </SendableSubscriberField>
            <Fields>
                <Field>
                    <CustomerKey>EmailAddress_Key</CustomerKey>
                    <Name>EmailAddress</Name>
                    <FieldType>EmailAddress</FieldType>
                </Field>
                <Field>
                    <CustomerKey>ChannelUser_Key</CustomerKey>
                    <Name>ChannelUser</Name>
                    <FieldType>Text</FieldType>
                </Field>
                <Field>
                    <CustomerKey>ChannelUser_EmailAddress_Key</CustomerKey>
                    <Name>ChannelUser_EmailAddress</Name>
                    <FieldType>EmailAddress</FieldType>
                </Field>
                <Field>
                    <CustomerKey>Demographic_Address_Key</CustomerKey>
                    <Name>Demographic_Address</Name>
                    <FieldType>Text</FieldType>
                </Field>
            </Fields>
        </Objects>
    </CreateRequest>
</s:body>
</s:envelope>

However I seem to get this 400 Bad Request as a response. What am I doing wrong?

1

Validating your call in SoapUI it appears your syntax is wrong in the envelope/header/body tag. They should be capitalized

Similar to

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="xsi">
   <s:Header>
      <fueloauth>access_token</fueloauth>
   </s:Header>
   <s:Body>

And corresponding closing tags

  • I think that might be partially it. – mercifulhop Apr 18 at 6:54
0

So after to the edit EazyE suggested, the request from that page was throwing another error:

"The SendableSubscriberField cannot be EmailAddress because the SUBSCRIBER_KEY business rule has been turned on" when creating a new Data Extension.

So this is the final request, with headers: Content-Type: text/xml and SOAPAction: Create

<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>token</fueloauth> 
  </soapenv:Header> 
  <soapenv:Body> 
      <CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI"> 
      <Options></Options> 
      <Objects xmlns:ns1="http://exacttarget.com/wsdl/partnerAPI" xsi:type="ns1:DataExtension"> 
        <CustomerKey>DataExtensionTesting</CustomerKey> 
        <Name>DataExtensionTesting</Name> 
        <IsSendable>true</IsSendable> 
        <SendableDataExtensionField> 
          <CustomerKey>EmailAddress_Key</CustomerKey> 
          <Name>EmailAddress</Name> 
          <FieldType>EmailAddress</FieldType> 
        </SendableDataExtensionField> 
        <SendableSubscriberField> 
          <Name>Subscriber Key</Name> 
          <Value/> 
        </SendableSubscriberField> 
        <Fields> 
          <Field> 
            <ObjectID xsi:nil="true"/> 
            <CustomerKey>SubscriberKey</CustomerKey> 
            <Name>SubscriberKey</Name> 
            <FieldType>Text</FieldType> 
            <IsRequired>true</IsRequired> 
            <IsPrimaryKey>true</IsPrimaryKey> 
            <MaxLength>100</MaxLength> 
          </Field> 
          <Field> 
            <CustomerKey>TestField1</CustomerKey> 
            <Name>TestField1</Name> 
            <FieldType>Text</FieldType> 
          </Field> 
          <Field> 
            <CustomerKey>EmailAddress_Key</CustomerKey> 
            <Name>EmailAddress</Name> 
            <FieldType>EmailAddress</FieldType> 
          </Field> 
          <Field> 
            <CustomerKey>Name</CustomerKey> 
            <Name>Name</Name> 
            <FieldType>Text</FieldType> 
          </Field> 
          <Field> 
            <CustomerKey>ImageURL</CustomerKey> 
            <Name>ImageURL</Name> 
            <FieldType>Text</FieldType> 
          </Field> 
        </Fields> 
      </Objects> 
    </CreateRequest> 
  </soapenv:Body> 
</soapenv: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.