I am trying to call the Web Services API to retrieve events using the code examples on the following pages:



However, when trying to run the sample .NET code, I receive an out of memory exception (see picture). I am receiving the correct number of records (e.g. if I try to retrieve the send events for a deployment of ten emails, I get an array of ten results), however the our of memory error occurs regardless of how many results I try to fetch.

Is this a problem with the API? Does anyone have a working example of event retrieval in .NET?

The method I am calling:

    public List<ClickEvent> RetrieveClickEvents(string JobID, ClientID clientID, out string status)
        List<ClickEvent> cE = new List<ClickEvent>();

        SimpleFilterPart sfp = new SimpleFilterPart();
        sfp.Property = "SendID";
        sfp.SimpleOperator = SimpleOperators.equals;
        sfp.Value = new string[] { JobID };

        RetrieveRequest rr = new RetrieveRequest();
        rr.ObjectType = "ClickEvent";

        rr.Properties = new string[] { "SendID", "EventDate", "SubscriberKey" };
        rr.Filter = sfp;
        rr.ClientIDs = new ClientID[] { clientID };

        APIObject[] results;

        string requestID;
        //string status;
        status = this.proxy.Retrieve(rr, out requestID, out results);


        if (status.ToUpper() == "OK")
            for (int i = 0; i < results.Length; )

        return cE;

enter image description here

  • 2
    Have you forgotten i++ in your for loop? – Boris Bachovski Jul 3 '15 at 5:25

As Bachovski says, the most likely cause of the out of memory error is this infinite loop:

for (int i = 0; i < results.Length; )

Because i is never incremented, the loop never terminates and the list grows until the available memory is used up.

So your code may work if you add the i++.


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.