9

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}}

Headers:

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

Raw SOAP:

<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>{{access_token}}</fueloauth>
  </soapenv:Header>
  <soapenv:Body>
    <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
      <RetrieveRequest>
        <ObjectType>DataExtensionObject[{{DE Name}}]</ObjectType>
        <Properties>email_address</Properties>
        <Properties>subscriber_key</Properties>
      </RetrieveRequest>
    </RetrieveRequestMsg>
  </soapenv:Body>
</soapenv:Envelope>

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">
  <wsse:UsernameToken>
    <wsse:Username>{{api_username}}</wsse:Username>
    <wsse:Password>{{api_user_password}}</wsse:Password>
  </wsse:UsernameToken>
</wsse:Security>

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/… – Gortonington Nov 29 '18 at 18:32
  • I removed xmlns="http://exacttarget.com", but it had no impact on the error I received. – JPB Nov 29 '18 at 19:19
  • 1
    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. – Gortonington Nov 29 '18 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 '18 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.