API eBay - тайм-аут getCategories

Попытка получить все категории от Ebay, чтобы засунуть в базу данных. Я попытался увеличить значение тайм-аута базового контекста API, но я все еще получаю тайм-аут после двух минут - что еще мне нужно сделать?

        var c = new eBay.Service.Call.GetCategoriesCall(this.apiContext);
        c.CategorySiteID = ((int)siteId).ToString(); // siteId is an eBay SiteCode enum value
        var version = c.GetCategoriesVersion();
        c.DetailLevelList = new DetailLevelCodeTypeCollection();
        c.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);
        c.ViewAllNodes = !onlyLeafCategories;
        c.Timeout = 1000*60*20;
        c.GetCategories(); // this causes a connection closed / timeout

1 ответ

Попробуйте этот код, он работает для меня:

// get all categories from eBay
                    ApiContext context = GetApiContext();

                    GetCategoriesCall apiCall = new GetCategoriesCall(context)
                    {
                        EnableCompression = true,
                        ViewAllNodes = true

                    };
                    apiCall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);
                    apiCall.GetCategories();

    public static ApiContext GetApiContext()
    {
        //apiContext is a singleton,
        //to avoid duplicate configuration reading
        if (apiContext != null)
        {
            return apiContext;
        }
        else
        {
            apiContext = new ApiContext();

            //set Api Server Url
            apiContext.SoapApiServerUrl = "https://api.ebay.com/wsapi";

            //set Api Token to access eBay Api Server
            ApiCredential apiCredential = new ApiCredential();
            apiCredential.eBayToken ="YOUR_TOKEN";
            apiContext.ApiCredential = apiCredential;
            //set eBay Site target to US
            apiContext.Site = eBay.Service.Core.Soap.SiteCodeType.US;
            return apiContext;
        }
    }
Другие вопросы по тегам