1

Goal: I'm attempting to get every automation in the system available to me under my account using the SOAP API in C#. It's also part of this guy's question. I know this has been asked but this is specifically my question about how to get every automation and not a three part question. If after you answer this you want to help him out, please do. That's why I've referenced his question in my post.

Setup: I have the WSDL (aka PartnerAPI) referenced under "Service References" in my C# class library project.*

What I've tried:
I've used a simplified version of the function suggested in the help documentation to retrieve them without any success. I've tried various combinations of rr.Properties with no success as it was an issue I had previously. I've even tried retrieving AutomationActivity and AutomationTask objects to try to help this guy using this simplified version of a request with no success.

public static void RetrieveAutomation(SoapClient soapClient)
{
    RetrieveRequest rr = new RetrieveRequest();
    rr.ObjectType = "Automation";

    rr.Properties = new string[] { "Name" };

    string sStatus = "";
    string sRequestId = "";
    APIObject[] rResults;

    sStatus = soapClient.Retrieve(rr, out sRequestId, out rResults);

    Console.WriteLine("Status: " + sStatus);
    Console.WriteLine("RequestID: " + sRequestId);

    foreach (Automation automation in rResults)
    {
        Console.WriteLine("Name: " + automation.Name);
    }
}

I've used the same simplified function with rr.ObjectType set to other types like folders, data extensions and user initiated send a.k.a the EmailSendDefinision.

* I've even compiled this class library and imported it as a "Plugin" into LinqPad and can run API calls on the fly.

How to do the above:
Make a new project, simplify the namespace to whatever you want, add the service reference url then compile. Put the dll produced into the plugins directory used by LinqPad and import the namespace whenever LinqPad detects it's not referenced. Real simple. If you have questions you can ask...as long as you realize this link is how.

  • What happens when you run the code provided? No results? Error? – Mac Mar 2 '16 at 20:54
  • I've dug into the response I'm getting from the system and it says: Object reference not set to an instance of an object. at ExactTarget.APIImplementation.Programs3.Soap.EqualsOperator.RetrieveAutomations(SoapRetrieveContext soapRetrieveContext) at ExactTarget.APIImplementation.Programs3.Soap.RetrieveCommandHandler.Retrieve(SoapRetrieveContext soapRetrieveContext) at ExactTarget.APIImplementation.Programs3.AutomationImpl.Retrieve(RetrieveRequest request) This means I have to specify the filter and the equals type and can never retrieve a list. – Dave Mar 4 '16 at 21:22
  • @Dave: were you eventually able to retrieve a list of all Automations? I have found that when using "Name" "isNotNull" as a Simple Filter still no results are returned. The filter seems to be mandatory. – Christopher Carswell Jul 6 '16 at 10:13
  • @Dave same here, I have to use a filter, but cannot get all automations. Did you ever figure it out? – garek007 Jun 6 at 20:40
2

check this post:

https://salesforce.stackexchange.com/a/62739/28187

you need "ProgramID" in attributes, and a simple filter

rr.Properties = new string[] { "Name","ProgramID" };

Although I received a different error: "no rows found"... "No rows were found" on “Automation” SOAP RetrieveRequest

Let me know how you go

Update:

Finally I found they have different names in SOAP message ObjectType for Automation, AutomationTask, AutomationActivity, passing these types in documentation would not work. Below are what in documentation and what you should be using Automation = Program AutomationTask = Task AutomationActivity = Activity

One Automation could have multiple AutomationTask, one AutomationTask could have multiple AutomationActivity Objects.

However if you try to pass "Program","Task", "Activity" in C# code it returns parse error, reference.cs couldn't understand the XML returned even it is valid XmlDocument.

The only workaround for me is to manually construct XML envelope and post it to endpoint.

  • The error you are getting is the same one if I use a simple filter like Name notequals "" – Dave Mar 24 '16 at 22:26
2

I have coded it with the same result, but I have found some interesting thing, you can call Retrieve method filtering by "isActive" parameter and "true" value, and after repeat the call filtering by "isActive" parameter and "false" value, and you will have the full set result of automations. The only thing is that I have to do in Async mode because of .Net Core 2.1 version only shows me Async calls once I associate the WFC service.

My code working:

List<Automation> AutomationList = new List<Automation>();

RetrieveRequest rr = new RetrieveRequest();
rr.ObjectType = "Automation";
rr.Properties = new String[] { "Name", "Description", "CustomerKey", "IsActive" };

SimpleFilterPart sfp = new SimpleFilterPart();
sfp.SimpleOperator = SimpleOperators.equals;
sfp.Property = "IsActive";
sfp.Value = new String[] { "true" };
rr.Filter = sfp;

RetrieveResponse rResp = await soapClient.RetrieveAsync(new RetrieveRequest1(rr));

for (int i = 0; i < rResp.Results.Length; i++)
{ 
    AutomationList.Add((Automation) rResp.Results[i]);
}

sfp.Value = new String[] { "false" };
rr.Filter = sfp;

// Add inactive automations
rResp = await soapClient.RetrieveAsync(new RetrieveRequest1(rr));
for (int i = 0; i < rResp.Results.Length; i++)
{
    AutomationList.Add((Automation)rResp.Results[i]);
}

return AutomationList;

I hope it will be useful :)

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.