I am trying to connect to the SFMC SOAP API using an access token that I've successfully retrieved. (I have successfully made REST API request using same token.)

I've been struggling with this for a few days, but it does feel as if I'm missing something simple. I'm hopeful that someone will point out whatever it is:

I've cobbled together the raw SOAP by reviewing SFMC docs and a number of Q&As on this site. Assume that I have just retrieved a new {{access token}}


POST URL : https://{{xxxxx}}.soap.marketingcloudapis.com/Service.asmx     
SOAPAction : Retrieve
Content Type : Text/XML; charset=UTF-8


<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">
    <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <ObjectType>DataExtensionObject[{{DE Name}}]</ObjectType>

SFMC does not appear to like this request. I receive a Failure when receiving data from the peer error.

I believe it is SFMC because if I were to swap out the {{access token}} line in the SOAP Header with this:

<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">

Then I get a response, but this time the error says: An invalid security token was provided

Additional (possibly) relevant details:

  • I'm performing these calls with R, using the httr package (which has worked for the access token and REST API requests)
  • Making the SOAP Request with invalid username/password gives me an Invalid Login error. I assume this means that my actual creds are making it past the login part of the process.

As mentioned, I do feel as if I'm missing something basic. Ideally, someone will be able to tell me how to get the {{access token}} variant working, but I'd settle for a good username/password connection too.

  • 1
    try removing: xmlns="http://exacttarget.com" this does not appear in the documentation and may be adversely affecting your call. docs: developer.salesforce.com/docs/… Nov 29, 2018 at 18:32
  • I removed xmlns="http://exacttarget.com", but it had no impact on the error I received.
    – JPB
    Nov 29, 2018 at 19:19
  • 2
    sorry just read it doesn't work with user/pass either? I would check permissions and ensure that a) your 'app' created in SFMC with client id/pass that you use to get token has correct permissions and b) that the API user you referenced has the correct permissions to access via API and to interact with Data Extensions, etc. Nov 29, 2018 at 20:16
  • So it turns out the above XML is valid and I have the correct user permissions. The Request successfully submits via the SoapUI platform. Which means that there is some difference in the HTTP request that is generated from my R script vs. SoapUI. I will post that answer when I figure it out, but for now I have a workable solution for testing some SOAP API requests.
    – JPB
    Nov 30, 2018 at 15:53
  • My team manages a postman collection that has a large collection of both SOAP and REST APIs. All of the SOAP calls use access token vs UN/PW that you can see for future examples. Currently the collection is available at: api.mcexperts.ninja We're working to get it added to the official Salesforce Postman network in the future. Jan 20, 2021 at 14:41


You must log in to answer this question.

Browse other questions tagged .