Skip to main content
Published: August 19 2010, 5:22:00 AMUpdated: November 28 2020, 8:42:28 PM

Trading API - C#.NET code sample to call GetSellerList

 

Here is a sample code in C# using .NET for making an asynchronous GetSellerList request. To use this sample, you will need to set a web reference to the eBay Web Service http://developer.ebay.com/webservices/latest/eBaySvc.wsdl

Code in the Program.cs file

using System;

using System.Collections.Generic;

using System.Text;

using GetSellerList_Sample.com.ebay.developer;

using System.Configuration;

 

namespace GetSellerList_Sample

{

    class Program

    {

        private static void Execute_GetSellerList()

        {

            try

            {

                eBayAPIInterfaceService service = new eBayAPIInterfaceService();

                service = GeteBayCustomService("GetSellerList", "SignInURL");

                GetSellerListRequestType request = new GetSellerListRequestType();

                request.Version = myVersion;

                request.GranularityLevelSpecified = true;                
                request.GranularityLevel = GranularityLevelCodeType.Coarse;

                // Setting the date-range filter. This call required either EndTimeFrom & EndTimeTo pair OR StartTimeFrom & StartTimeTo pair

                // as a required input parameter.

                string strStartTimeFrom = "2010-02-15T00:00:00.000Z";

                string strStartTimeTo = "2010-05-17T23:59:59.999Z";

                request.StartTimeFromSpecified = true;

                request.StartTimeFrom = Convert.ToDateTime(strStartTimeFrom).ToUniversalTime();

                request.StartTimeToSpecified = true;

                request.StartTimeTo = Convert.ToDateTime(strStartTimeTo).ToUniversalTime();

                // Setting the Pagination which is a required input parameter for GetSellerList call

                PaginationType pagination = new PaginationType();

                pagination.EntriesPerPageSpecified = true;

                pagination.EntriesPerPage = 5;

                pagination.PageNumberSpecified = true;

                pagination.PageNumber = 1;

                request.Pagination = pagination;

 

                GetSellerListResponseType response = new GetSellerListResponseType();

                response = service.GetSellerList(request);

                Console.Clear();

                Console.WriteLine("Ack: " + response.Ack);

                if (response.Ack == AckCodeType.Success)

                {

                    PaginationResultType paginationResult = response.PaginationResult;

                    Console.WriteLine("TotalNumberOfPages: " + paginationResult.TotalNumberOfPages);

                    Console.WriteLine("TotalNumberOfEntries: " + paginationResult.TotalNumberOfEntries);

                    Console.WriteLine();

                    // Iterate through the ItemArray in the response for item details

                    foreach (ItemType item in response.ItemArray)

                    {

                        Console.WriteLine("ItemID: " + item.ItemID);

                        Console.WriteLine("Title: " + item.Title);

                        Console.WriteLine("-----------------------------");

                    }

                }

                else

                {

                    ErrorType[] errors = response.Errors;

                    foreach (ErrorType error in errors)

                    {

                        Console.WriteLine("ErrorCode: " + error.ErrorCode);

                        Console.WriteLine("Severity: " + error.SeverityCode);

                        Console.WriteLine("LongMessage: " + error.LongMessage);                       

                    }

                }

            }

            catch (Exception ex)

            {

                throw ex;

            }

        }

 

        private static eBayAPIInterfaceService GeteBayCustomService(string callName, string url)

        {

            eBayAPIInterfaceService service = new eBayAPIInterfaceService();

            try

            {

                myToken = "YOUR_TOKEN";

                myVersion = "VERSION";

                mySite = "SITEID";

                signinURL = "SignInURL";

                string endpointURL = signinURL + "?callname=" + callName + "&siteid=" + mySite + "&version=" + myVersion + "&Routing=new";

                service.Url = endpointURL;

                service.RequesterCredentials = new CustomSecurityHeaderType();

                service.RequesterCredentials.eBayAuthToken = myToken;

            }

            catch (Exception ex)

            {

                throw ex;

            }

            return service;

        }

    }

}

 

Version Info

The code example above was based on the versions specified below:

API Schema Version

681

How well did this answer your question?
Answers others found helpful