خرید بک لینک

Vote count: 0

I am using postcodes.io api to get Geolocation information based on postcodes. It's working fine. But this API has a limitation that it can accept only 100 postcodes per request. I have around 300 postcodes. I am thinking of making calls to API parallely and aggregate the response after getting everything.

var httpClient = _httpClientFactory.GetHttpClient("GeolocationAPI", postCodeServiceUrl, _httpLogger);

            // chunks the list by 100 items and retus the collection
            var postcodeChunks = postcodes.ChunkBy(100);  
             postcodeChunks.ForEach(
                postcodeList =>
                    {
                        var response = httpClient
                            .Post
                            <MultipleGeolocationInfoRequest,
                                GetGeolocationResult<GetGeolocationResult<GeolocationInfo>[]>>(
                                    "postcodes",
                                    new MultipleGeolocationInfoRequest {Postcodes = postcodeList.ToArray()});
                    }
                );

ChunkBy extension method is retuing the list of lists and each list containing 100 postcodes.

I am facing difficulty in aggregating the retu response and handling exceptions if any. The response from each call is also a collection.

API : http://postcodes.io/

asked 5 mins ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 18 خرداد 1395 ساعت: 23:46

صفحه بندی