2

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

http://help.exacttarget.com/en/technical_library/web_service_guide/technical_articles/retrieving_open_events_details/

http://help.exacttarget.com/en/technical_library/web_service_guide/technical_articles/retrieve_sentevent_details_for_job/

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);


        //results.Length

        if (status.ToUpper() == "OK")
        {
            for (int i = 0; i < results.Length; )
            {
                cE.Add((ClickEvent)results[i]);
            }
        }

        return cE;
    }

enter image description here

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

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

for (int i = 0; i < results.Length; )
{
    cE.Add((ClickEvent)results[i]);
}

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++.

| improve this answer | |

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.