Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question re GetByPageUrl in incremental ticket export #121

Closed
DCJackson opened this issue Jan 21, 2015 · 2 comments
Closed

Question re GetByPageUrl in incremental ticket export #121

DCJackson opened this issue Jan 21, 2015 · 2 comments

Comments

@DCJackson
Copy link

Hello,
GetByPageUrl is working well for me getting view data (GroupTicketResponse). I am also using it to get all tickets in the incremental export (TicketExportResponse).

It is here that I randomly receive "Object reference not set to an instance of an object" on my GetByPageUrl call. So, I've been hyper-vigilant about checking for nulls everywhere, but it still occurs.

Code:

        var initialResponse = api.Tickets.GetInrementalTicketExport(startDate);

        int totalFetched = 0;

        if (initialResponse != null)
        {
            if (initialResponse.Results != null)
            {
                eventLog.WriteEntry("Number of tickets in first call to incremental export: " + initialResponse.Results.Count());
                totalFetched = initialResponse.Results.Count();

                responseList.Add(initialResponse);
                var nextPage = initialResponse.NextPage;


                if (initialResponse.Results.Count() >= 1000)
                {
                    TicketExportResponse paginationResponse = new TicketExportResponse();

                    do
                    {
                        //sleep 
                        System.Threading.Thread.Sleep(1000 * 65); // 65 seconds (This is necessary as this API call is rate limited)

                        if (!string.IsNullOrEmpty(nextPage))
                        {
                            paginationResponse = api.Tickets.GetByPageUrl<TicketExportResponse>(nextPage.Trim()); //**exception occurs here**
                            if (paginationResponse != null && !string.IsNullOrEmpty(paginationResponse.NextPage))
                            {
                                nextPage = paginationResponse.NextPage;
                            }
                        }

                        if (paginationResponse != null && paginationResponse.Results != null)
                        {
                            totalFetched = totalFetched + paginationResponse.Results.Count();
                            eventLog.WriteEntry("Just fetched another " + paginationResponse.Results.Count() + " records. Total so far: " + totalFetched);
                            responseList.Add(paginationResponse);
                        }

                    } while (paginationResponse != null && paginationResponse.Results != null && paginationResponse.Results.Count >= 1000);
                }
            }
        }

Am I missing something or is there a known issue? It pulls tickets great in batches of 1000 but...every now and again I get the Object Reference exception. It's random.

(I also sometimes get a 502 Bad Gateway and have put in re-try logic for that)

Thanks a lot in advance. Great API you created!
-DCJ

@mozts2005
Copy link
Member

Can you please send us a test case for this?

@mozts2005
Copy link
Member

I am unable to reproduce this issue until we have it in reproduce-able test case I am closing the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants