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.
Attribution to: pantsleftinwash
Possible Suggestion/Solution #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>
Attribution to: Jon Sakas
Possible Suggestion/Solution #2
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>
Attribution to: pantsleftinwash
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/34761