Am new to SOAP and newer to SFMC SOAP API. I am trying to retrieve DE rows via SOAP API and couple of questions, as I keep hitting a 500 error - internal server error.

My code is below - first question - does the request envelope format look ok? To me it aligns to what is required and what I have seen elsewhere. Second question - have I got the request itself set ok? I cant find what should be put in the SOAPAction header param.

Any pointers would be really appreciated. Im not finding this API particularly easy to figure out..

public with sharing class SfmcSoapIntegration {

// from https://salesforce.stackexchange.com/questions/200593/making-a-callout-in-apex-to-marketing-cloud-soap-api

private static String makeHTTPXMLPost(String endPoint, String soapBody){
    Http h = new Http();
    HttpRequest r = new HttpRequest();
    HttpResponse s = h.send(r);
    return s.getBody();

// from https://salesforce.stackexchange.com/questions/200593/making-a-callout-in-apex-to-marketing-cloud-soap-api

public static String performMCRetrieveData(String recordId, String dataExtensionName ){
    String soapEnvelopeTemplate =
    '<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'+
    '       <Header>'+
    '          <Security xmlns="https://www.marketingcloud.com/">'+
    '             <fueloauth>{0}</fueloauth>'+
    '          </Security>'+
    '       </Header>'+
    '       <Body>'+
    '          <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">'+
    '             <RetrieveRequest>'+
    '                <ObjectType>DataExtensionObject[{1}]</ObjectType>'+
    '                <Properties>CurrentTier</Properties>'+
    '                   <Filter xsi:type="SimpleFilterPart">'+
    '                   <Property>CurrentTier</Property>'+
    '                   <SimpleOperator>equals</SimpleOperator>'+
    '                   <Value>1</Value>'+
    '                </Filter>'+
    '             </RetrieveRequest>'+
    '          </RetrieveRequestMsg>'+
    '       </Body>'+
    '    </Envelope>';

    SfmcRestApi restApi = new SfmcRestApi();
    String accessToken = restApi.getAccessToken();

    String body = String.format(soapEnvelopeTemplate, 
                                new String[]{ accessToken, dataExtensionName  });
    return makeHTTPXMLPost('https://MYSERVER.soap.marketingcloudapis.com/Service.asmx' , body );

1 Answer 1


So the answer was that the xml payload header as shown below was wrong -- the Security tags are not required around the fueloauth tags. Once they were removed the 500 error was resolved.

'   <Security xmlns="https://www.marketingcloud.com/">'+
'             <fueloauth>{0}</fueloauth>'+
'   </Security>'+

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .