0

I want to get SubscriberStatusEvent using:

https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/retrieving_the_subscriberstatusevent.html

the following code returns OK but there is no data. What might be the problem?

    <?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">
    <s:Header>
        <a:Action s:mustUnderstand="1">Retrieve</a:Action> 
        <a:To s:mustUnderstand="1">https://{{et_subdomain}}.soap.marketingcloudapis.com/Service.asmx</a:To> 
        <fueloauth xmlns="http://exacttarget.com">{{dne_etAccessToken}}</fueloauth> 
    </s:Header> 
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
    <RetrieveRequest>
    <ObjectType>SubscriberStatusEvent</ObjectType>
    <QueryAllAccounts>true</QueryAllAccounts>
    <Properties>Client.ID</Properties>
    <Properties>CreatedDate</Properties>
    <Properties>CurrentStatus</Properties>
    <Properties>ObjectID</Properties>
    <Properties>PreviousStatus</Properties>
    <Properties>ReasonUnsub</Properties>
    <Properties>SubscriberID</Properties>
    <Properties>SubscriberKey</Properties>
    <Filter xsi:type="SimpleFilterPart" xmlns:par="http://exacttarget.com/wsdl/partnerAPI">
                <Property>SubscriberKey</Property>
                  <SimpleOperator>equals</SimpleOperator>
                  <Value>[email protected]</Value>
    </Filter>
     </RetrieveRequest> 
     </RetrieveRequestMsg>
     </s:Body>
     </s:Envelope>

POSTMAN Python code:

import http.client

conn = http.client.HTTPSConnection("DOMAIN.soap.marketingcloudapis.com")
payload = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" xmlns:u=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\\\">\n    <s:Header>\n        <a:Action s:mustUnderstand=\"1\">Retrieve</a:Action> \n        <a:To s:mustUnderstand=\"1\">https://DOMAIN.soap.marketingcloudapis.com/Service.asmx</a:To> \n        <fueloauth xmlns=\"http://exacttarget.com\">OAUTHTOKEN</fueloauth> \n    </s:Header> \n    <s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n    <RetrieveRequestMsg xmlns=\"http://exacttarget.com/wsdl/partnerAPI\">\n    <RetrieveRequest>\n    <ObjectType>SubscriberStatusEvent</ObjectType>\n    <QueryAllAccounts>true</QueryAllAccounts>\n    <Properties>Client.ID</Properties>\n    <Properties>CreatedDate</Properties>\n    <Properties>CurrentStatus</Properties>\n    <Properties>ObjectID</Properties>\n    <Properties>PreviousStatus</Properties>\n    <Properties>ReasonUnsub</Properties>\n    <Properties>SubscriberID</Properties>\n    <Properties>SubscriberKey</Properties>\n    <Filter xsi:type=\"SimpleFilterPart\" xmlns:par=\"http://exacttarget.com/wsdl/partnerAPI\">\n                <Property>SubscriberKey</Property>\n                  <SimpleOperator>equals</SimpleOperator>\n                  <Value>[email protected]</Value>\n    </Filter>\n     </RetrieveRequest> \n     </RetrieveRequestMsg>\n     </s:Body>\n     </s:Envelope>"
headers = {
  'Content-Type': 'application/xml'
}
conn.request("POST", "/Service.asmx", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

2 Answers 2

0

I'd definitely recommend testing any SFMC API call in Postman first. The SFMC Collection is more recent (and relevant) than the SDKs.

Postman1

Postman2

You're missing part of the endpoint URL. Here's a Python export from Postman for my test call:

import http.client

conn = http.client.HTTPSConnection("YOURTENANT.soap.marketingcloudapis.com")
payload = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" xmlns:u=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">\n <s:Header>\n <a:Action s:mustUnderstand=\"1\">Retrieve</a:Action>\n <a:To s:mustUnderstand=\"1\">https://YOURTENANT.soap.marketingcloudapis.com/Service.asmx</a:To>\n <fueloauth xmlns=\"http://exacttarget.com\">YOURAUTHTOKEN</fueloauth>\n </s:Header>\n <s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n <RetrieveRequestMsg xmlns=\"http://exacttarget.com/wsdl/partnerAPI\">\n <RetrieveRequest>\n <ObjectType>SubscriberStatusEvent</ObjectType>\n <QueryAllAccounts>true</QueryAllAccounts>\n<Properties>Client.ID</Properties>\n<Properties>CreatedDate</Properties>\n<Properties>CurrentStatus</Properties>\n<Properties>ObjectID</Properties>\n<Properties>PreviousStatus</Properties>\n<Properties>ReasonUnsub</Properties>\n<Properties>SubscriberID</Properties>\n<Properties>SubscriberKey</Properties>\n </RetrieveRequest>\n </RetrieveRequestMsg>\n </s:Body>\n</s:Envelope>"
headers = {
  'Content-Type': 'text/plain'
}
conn.request("POST", "/Service.asmx", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
1
  • I used POSTMAN as you recommended. I also changed the xml file to be similar to yours. I am getting OK as a response but there is no data even though I can see there is a subscriber with the email address who unsubscribed in the all subscribers list.
    – DonnyDarko
    Commented Apr 28, 2022 at 9:29
0

Please check your BU unsubscribe settings within Setup. My understanding is that the SubscriberStatusEvent will only populate if you have configured the BU's Unsubscribe Settings as: Subscribers will be unsubscribed from all business units in the Enterprise.

Furthermore, you MUST ensure that you create and license your installed package in the TOP LEVEL parent account.

If anyone is attempting to retrieve via WS Proxy, then you need to execute the code in the PARENT Business Unit since impersonation does not work bottom-up.

The key clue is in the documentation:

This call only logs events at the All Subscriber list level.

Since the All Subscribers list exists at the enterprise level, then this particular API call needs to be made at the enterprise level as well.

You must log in to answer this question.

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