Example #1
0
        public async Task <List <VideoChannel> > GetVideoChannels()
        {
            var requestUrl = string.Format("{0}/_api/VideoService/Channels", videoPortalUrl);

            Func <HttpRequestMessage> requestCreator = () =>
            {
                HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUrl);
                request.Headers.Add("Accept", "application/json;odata=verbose");
                return(request);
            };


            var httpClient = new HttpClient();

            var response = await SendRequestAsync(sharePointAccessToken, sharePointServiceEndpointUri, httpClient, requestCreator);

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

            var jsonResponse = JsonConvert.DeserializeObject <VideoChannelCollection>(responseString);

            // convert to model object
            var channels = new List <VideoChannel>();

            foreach (var videoChannel in jsonResponse.Data.Results)
            {
                var channel = new VideoChannel
                {
                    Id                = videoChannel.Id,
                    HtmlColor         = videoChannel.TileHtmlColor,
                    Title             = videoChannel.Title,
                    Description       = videoChannel.Description,
                    ServerRelativeUrl = videoChannel.ServerRelativeUrl
                };
                channels.Add(channel);
            }

            return(channels);
        }
Example #2
0
        public async Task<List<VideoChannel>> GetVideoChannels()
        {
            var requestUrl = string.Format("{0}/_api/VideoService/Channels", videoPortalUrl);

            Func<HttpRequestMessage> requestCreator = () =>
            {
                HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUrl);
                request.Headers.Add("Accept", "application/json;odata=verbose");
                return request;
            };


            var httpClient = new HttpClient();

            var response = await SendRequestAsync(sharePointAccessToken, sharePointServiceEndpointUri, httpClient, requestCreator);

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

            var jsonResponse = JsonConvert.DeserializeObject<VideoChannelCollection>(responseString);

            // convert to model object
            var channels = new List<VideoChannel>();

            foreach (var videoChannel in jsonResponse.Data.Results)
            {
                var channel = new VideoChannel
                {
                    Id = videoChannel.Id,
                    HtmlColor = videoChannel.TileHtmlColor,
                    Title = videoChannel.Title,
                    Description = videoChannel.Description,
                    ServerRelativeUrl = videoChannel.ServerRelativeUrl
                };
                channels.Add(channel);
            }

            return channels;
        }