skip to Main Content

I write C# application, which gets orders from Ebay.

The problem is I can get only 100 orders from getOrders.ApiResponse.OrderArray.

I have about 1000 orders. How to get other 900? In another words, how to iterate through ebay orders by using HasMoreOrders call and Pagination.PageNumber?

2

Answers


  1. In the first GetOrders call itself you can find the total no of items and Pages in the result

    You should loop through each page & call GetOrders API call with different page number

    For(int index=0; index<Orders.Pages; index++)
    {
    // Build GetOrders Request with PageNumber - index
    
    // Call GetOrders API with page number 
    
    // Manipulate result
    }
    
    Login or Signup to reply.
  2. The response itself contains the current page number and total number of pages. You will need to do a new request per page.

    Take a look at the following code I wrote to get all results from each page (this is with the Finding API, but works the same for all other eBay APIs):

    var response = GetResults(findingService, request, currentPageNumber);
    if (response.ack == AckValue.Success)
    {
        var result = response.searchResult;
        if (result != null && result.count > 0)
        {
            // TODO process result
    
            for (var i = response.paginationOutput.pageNumber; i < response.paginationOutput.totalPages; i++)
            {
                currentPageNumber += 1;
    
                response = GetResults(findingService, request, currentPageNumber);
                result = response.searchResult;
    
                // TODO process result
            }
        }
    }
    
    private FindCompletedItemsResponse GetResults(CustomFindingService service, FindCompletedItemsRequest request, int currentPageNumber)
    {
        request.paginationInput = GetNextPage(currentPageNumber);
        return service.findCompletedItems(request);
    }
    
    private PageinationInput GetNextPage(int pageNumber)
    {
        return new PaginationInput
        {
            entriesPerPageSpecified = true,
            entriesPerPage = 100,
            pageNumberSpecified = true,
            pageNumber = pageNumber  
        };
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search