Example #1
0
        public static async Task <dynamic> GetAllLists(HttpClient client, Queue <string> folderIDs)
        {
            Queue <List> allLists = new Queue <List>();

            while (folderIDs.Count > 0)
            {
                string uri = $"{ConfigDictionary.Config()["ClickUpAPIURLRoot"]}/folder/{folderIDs.Dequeue()}/list?archived=false";

                try
                {
                    HttpResponseMessage response = await client.GetAsync(uri);

                    string responseData = await response.Content.ReadAsStringAsync();

                    ListsRoot listsRoot = JsonConvert.DeserializeObject <ListsRoot>(responseData);

                    for (int i = 0; i < listsRoot.Lists.Count; i++)
                    {
                        allLists.Enqueue(listsRoot.Lists[i]);
                    }
                }
                catch (HttpRequestException ex)
                {
                    return(ex);
                }
            }

            return(allLists);
        }
Example #2
0
        private async void GetLists(GetListsEventArgs args)
        {
            try
            {
                using (HttpClient client = new HttpClient())
                {
                    Results.InitializeHttpClient(client, args.Organization.PAT);

                    var requestUri = $"{args.Organization.Uri}/_apis"
                                     + "/work/processes/lists"
                                     + "?api-version=6.0-preview.1";

                    var exchange = Results.InitializeExchange(client, requestUri);

                    using (HttpResponseMessage response = await client.GetAsync(requestUri))
                    {
                        Results.RecordExchangeResponse(response, exchange);

                        response.EnsureSuccessStatusCode();

                        string outJson = await response.Content.ReadAsStringAsync();

                        JObject o = JObject.Parse(outJson);

                        ListsRoot resultRoot = JsonConvert.DeserializeObject <ListsRoot>(outJson);

                        Results.ResultItems = new ObservableCollection <List>(resultRoot.value);

                        IEnumerable <string> continuationHeaders = default;

                        bool hasContinuationToken = response.Headers.TryGetValues("x-ms-continuationtoken", out continuationHeaders);

                        Results.Count = Results.ResultItems.Count;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, Common.LOG_CATEGORY);
                ExceptionDialogService.DisplayExceptionDialog(DialogService, ex);
            }

            EventAggregator.GetEvent <HttpExchangeEvent>().Publish(Results.RequestResponseExchange);
        }