/// <summary>
        /// Creates a Cloud Skills Challenge based on the parameter.
        /// </summary>
        /// <param name="contest">The argurments to pass to the server.</param>
        /// <returns>The ContestResponse from the server.</returns>
        private async Task <ContestResponse> CreateChallengeAsync(ContestRequest contest)
        {
            Uri    uri  = new Uri($"{apiRoot}{ApiPathContests}");
            string json = JsonConvert.SerializeObject(contest);

            try
            {
                HttpResponseMessage response = await httpClient.PostAsync(uri,
                                                                          new StringContent(json, Encoding.UTF8, MediaTypeJson));

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

                ContestResponse result = JsonConvert.DeserializeObject <ContestResponse>(jsonResponse);
                return(result);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(string.Format("Error: {0}; Request details: {1}", ex.Message, json));
                throw;
            }
        }
        /// <summary>
        /// Creates a challenge for each collection based on template
        /// </summary>
        /// <param name="learningPaths">The list of collections to be used in the template.</param>
        /// <param name="request">The template to be used to created the contest.</param>
        /// <returns>The ContestResponse.</returns>
        private async Task <List <ContestResponse> > CreateCollectionChallengesAsync(IList <LearningPath> learningPaths, ContestRequest request)
        {
            if (learningPaths == null)
            {
                throw new ArgumentNullException($"{nameof(learningPaths)} is null");
            }

            var results = new List <ContestResponse>();

            request.Name = $"{request.Name} | {DateTime.Now.ToString(ContestDateFormat)} {ContestNameTag}";

            foreach (LearningPath lp in learningPaths)
            {
                request.CollectionUrl  = lp.CollectionUrl;
                request.CollectionName = lp.CollectionName;
                request.CollectionID   = lp.GetCollectionId();

                if (!string.IsNullOrWhiteSpace(request.CollectionName) &&
                    request.CollectionUrl.StartsWith(MsLearnUriPrefix) &&
                    !string.IsNullOrWhiteSpace(request.CollectionName))
                {
                    ContestResponse result = await CreateChallengeAsync(request);

                    results.Add(result);
                }
            }

            return(results);
        }