3

I need to pull all TriggeredSends with the word "Confirmation" in the name of it that were sent between a specified date. The reason I need to pull by the name, and not an ID is because this is going to be used across multiple clients with different IDs. Our company has a naming standard that is used across all the accounts.

TriggeredSendSummaries have every property that I need to work with (UniqueOpens, UniqueClicks, etc). I can successfully pull the TriggeredSendSummaries of TriggeredSends, but I can't tell which TriggeredSend they are a summary of. I see that TriggeredSendDefinitions are a property of the summaries, and the definitions include the needed name I need to check for. The problem is I get an error saying that Error: The Request Property(s) TriggeredSendDefintion do not match with the fields of TriggeredSendSummary retrieve.

I know the issue is not the Date filter because I have that working in another API call perfectly fine.

Here is my .NET code if it helps anyone:

 RetrieveRequest triggeredRetrieveRequest = new RetrieveRequest();
 triggeredRetrieveRequest.ObjectType = "TriggeredSendSummary";
 triggeredRetrieveRequest.Properties = new String[] { "Sent", "UniqueOpens", "UniqueClicks", "CustomerKey", "TriggeredSendDefintion"}; //Fails on TriggeredSendDefinition

 SimpleFilterPart dateFilter = new SimpleFilterPart();
 dateFilter.Property = "SentDate";
 dateFilter.SimpleOperator = SimpleOperators.between;
 dateFilter.DateValue = new DateTime[2];

 //Parse date strings
 DateTime start = DateTime.SpecifyKind(DateTime.Parse(myStartDate + " 00:00:00.000"), DateTimeKind.Utc);
 var startKind = start.Kind;
 DateTime end = DateTime.SpecifyKind(DateTime.Parse(myEndDate + " 00:00:00.000"), DateTimeKind.Utc);
 var endKind = start.Kind;

 //Make input dates be included within the between
 dateFilter.DateValue[0] = start.AddDays(-1).ToLocalTime();
 dateFilter.DateValue[1] = end.AddDays(1).ToLocalTime();

 //Would like to add a complex filter here to check for name of TriggeredSendDefinition name

 triggeredRetrieveRequest.Filter = dateFilter;

 APIObject[] triggeredResults = null;
 String triggeredRequestId = null;
 String triggeredResponse = soapClient.Retrieve(triggeredRetrieveRequest, out triggeredRequestId, out triggeredResults);

1 Answer 1

0

I was on the right track, but turns out I needed to make a Request object for SentEvents, ClickEvents, etc. querying by the date and TriggeredSendDefinitionObjectID as a complex filter.

Here's how to do it in C#:

 RetrieveRequest triggeredRetrieveRequest = new RetrieveRequest();
 triggeredRetrieveRequest.ObjectType = "SentEvent";
 triggeredRetrieveRequest.Properties = new String[] { "SendID", "EventDate" };

 //Create first simple filter for dates
 SimpleFilterPart dateFilter = new SimpleFilterPart();
 dateFilter.Property = "SentDate";
 dateFilter.SimpleOperator = SimpleOperators.between;
 dateFilter.DateValue = new DateTime[2];

 //Parse date strings
 DateTime start = DateTime.SpecifyKind(DateTime.Parse(myStartDate + " 00:00:00.000"), DateTimeKind.Utc);
 var startKind = start.Kind;
 DateTime end = DateTime.SpecifyKind(DateTime.Parse(myEndDate + " 00:00:00.000"), DateTimeKind.Utc);
 var endKind = start.Kind;

 //Make input dates be included within the between
 dateFilter.DateValue[0] = start.AddDays(-1).ToLocalTime();
 dateFilter.DateValue[1] = end.AddDays(1).ToLocalTime();

 //Create second part of complex filter for TriggeredSendDefinitionObjectID
 SimpleFilterPart sfp = new SimpleFilterPart();
 sfp.SimpleOperator = SimpleOperators.equals;
 sfp.Property = "TriggeredSendDefinitionObjectID";
 sfp.Value = definitionIds.ToArray<string>();

 //Combine the two simple filters into one complex filter
 ComplexFilterPart cfp = new ComplexFilterPart();
 cfp.LeftOperand = sfp;
 dateFilter.Property = "EventDate";
 cfp.RightOperand = dateFilter;
 cfp.LogicalOperator = LogicalOperators.AND;

 retrieveRequest.Filter = cfp; //Set the complex filter to the request

 //Now make the actual request!
 APIObject[] results = null;
 String requestId = null;
 String response = null;
 int total = 0;

 do
 {
     response = soapClient.Retrieve(retrieveRequest, out requestId, out results);
     total += results.Length; //Add to the total of return results

     //Make a new ContinueRequest if needed
     retrieveRequest = new RetrieveRequest();
     retrieveRequest.ContinueRequest = requestId; 
 }
 while (response.Equals("MoreDataAvailable"));//This means there are more than 2500 records so keep looping

This can be done with SentEvents, OpenEvents, ClickEvents, BounceEvents, UnsubEvents, etc. so that you can actually count TriggeredSends between dates!

You must log in to answer this question.

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