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.
xmlns="http://exacttarget.com"
this does not appear in the documentation and may be adversely affecting your call. docs: developer.salesforce.com/docs/…xmlns="http://exacttarget.com"
, but it had no impact on the error I received.