2

I am trying to retrieve a list of all attributes available on the Subscriber Object via the SOAP API.

I have tried the example found here, but that retrieves all of the subscribers which will be far too heavy when the database is properly filled.

I have attempted to adjust the sample to include BatchSize as suggested here so that just one subscriber would be retrieved, but that seems to not have any efect and all rows are returned:

<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>Subscriber</ObjectType>
            <Properties>ID</Properties>
            <Options>
                <BatchSize>1</BatchSize>
            </Options>
        </RetrieveRequest>
    </RetrieveRequestMsg>
</s:Body>

How do I get either just the available attributes or retrieve just one subscriber to get the attributes from?

I could obviously use a filter if I was 100% sure that that user would be in the subscribers list - but that doesn't really feel like a stable solution since I can't really ever be 100% sure.

3

As per jsakas suggestion here the only way to achieve this goal is to do 3 separate requests:

First create a subscriber (the email should be implausible, but valid and not spam like - I tried 'test@test.com' first and that got rejected as it 'TriggeredSpamFilter' so I decided to use a mail address at my company's domain to get past this)

<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <Options>
            <SaveOptions>
                <SaveOption>
                    <PropertyName>*</PropertyName>
                    <SaveAction>UpdateAdd</SaveAction>
                </SaveOption>
            </SaveOptions>
        </Options>
        <Objects xsi:type="Subscriber">
            <PartnerKey xsi:nil="true"/>
            <ObjectID xsi:nil="true"/>
            <EmailAddress>made.up.user@yourcompany.com</EmailAddress>
            <Attributes>
                <Name>First Name</Name>
                <Value>Joe</Value>
            </Attributes>
            <Attributes>
                <Name>Last Name</Name>
                <Value>Bloggs</Value>
            </Attributes>
            <Attributes>
                <Name>Full Name</Name>
                <Value>Joe Bloggs</Value>
            </Attributes>
            <SubscriberKey>made.up.user@yourcompany.com</SubscriberKey>
        </Objects>
    </CreateRequest>
</s:Body>

Next stage is to make a request for this user as the response from the create request only contains those attributes that you supplied in the request.

<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>Subscriber</ObjectType>
            <Properties>ID</Properties>
            <Properties>EmailAddress</Properties>
            <Properties>SubscriberKey</Properties>
            <Filter xsi:type="SimpleFilterPart">
                <Property>EmailAddress</Property>
                <SimpleOperator>equals</SimpleOperator>
                <Value>made.up.user@yourcompany.com</Value>
            </Filter>
        </RetrieveRequest>
    </RetrieveRequestMsg>
</s:Body>

Then parse the response to retrieve the available attributes:

<soap:Body>
    <RetrieveResponseMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <OverallStatus>OK</OverallStatus>
        <RequestID>bd42d205-faa2-449a-bf84-05cdfb3136e0</RequestID>
        <Results xsi:type="Subscriber">
            <PartnerKey xsi:nil="true" />
            <ID>124176</ID>
            <ObjectID xsi:nil="true" />
            <EmailAddress>made.up.user@yourcompany.com</EmailAddress>
            <Attributes>
                <Name>Full Name</Name>
                <Value>Joe Bloggs</Value>
            </Attributes>
            <Attributes>
                <Name>Email Address</Name>
                <Value>made.up.user@yourcompany.com</Value>
            </Attributes>
            <Attributes>
                <Name>User Defined</Name>
                <Value />
            </Attributes>
            <Attributes>
                <Name>First Name</Name>
                <Value>Joe</Value>
            </Attributes>
            <Attributes>
                <Name>Last Name</Name>
                <Value>Bloggs</Value>
            </Attributes>
            <Attributes>
                <Name>User Identifier</Name>
                <Value />
            </Attributes>
            <Attributes>
                <Name>Card Id</Name>
                <Value />
            </Attributes>
            <SubscriberKey>made.up.user@yourcompany.com</SubscriberKey>
        </Results>
    </RetrieveResponseMsg>
</soap:Body>

And finally delete the fake user:

<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <DeleteRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <Options/>
        <Objects xsi:type="Subscriber">
            <PartnerKey xsi:nil="true"/>
            <ObjectID xsi:nil="true"/>
            <EmailAddress>made.up.user@yourcompany.com</EmailAddress>
            <SubscriberKey>made.up.user@yourcompany.com</SubscriberKey>
        </Objects>
    </DeleteRequest>
</s:Body>
1

It seems like you are asking two questions here. First, how do you retrieve a single subscriber. Second, how do you retrieve custom Profile Attributes.

If you want to look up a single subscriber or multiple subscribers you need to use a filter. This is how you tell if the subscriber exists. If the subscriber exists you will get a Results node in the response XML.

To retrieve custom Profile attributes, which are attributes that you have created and do not come standard, you must add the "ID" property to your request.

The following code will retrieve a single subscriber as well as all of their profile attributes:

<ns1:Body>
  <ns0:RetrieveRequestMsg>
    <ns0:RetrieveRequest>
      <ns0:ObjectType>Subscriber</ns0:ObjectType>
      <ns0:Properties>EmailAddress</ns0:Properties>
      <ns0:Properties>SubscriberKey</ns0:Properties>
      <ns0:Properties>Status</ns0:Properties>
      <ns0:Properties>UnsubscribedDate</ns0:Properties>
      <ns0:Properties>CreatedDate</ns0:Properties>
      <ns0:Properties>Client.ID</ns0:Properties>
      <ns0:Properties>ID</ns0:Properties>
      <ns0:Filter xsi:type="ns0:SimpleFilterPart">
        <ns0:Property>SubscriberKey</ns0:Property>
        <ns0:SimpleOperator>equals</ns0:SimpleOperator>
        <ns0:Value>test@gmail.com</ns0:Value>
      </ns0:Filter>
    </ns0:RetrieveRequest>
  </ns0:RetrieveRequestMsg>
</ns1:Body>
2
  • Thanks for the answer, but no - that is not what I am asking. As I stated in the question retrieving 1 subscriber using a filter is an obvious and undesirable answer. Imagine there are no subscribers present yet or that I do not have enough information to create a filter. I just want to know what attributes are available to me to add to new users. May 12 '14 at 6:18
  • I see what you are trying to do now, but I'm afraid it may not be possible with the current API. I have confirmed that BatchSize does not have any effect when retrieving Subscribers. ET will only give you 2500 max subscribers back per request so even if you have a large subscriber set it may still be a viable option. As far as retrieving custom profile attributes with no subscribers in the account, I do not think this is possible either. My suggestion would be to create a test subscriber, and then retrieve it. You can then delete it if you don't need it.
    – Jon Sakas
    May 12 '14 at 18:16

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.