예제 #1
0
        private PowerBIApiResponse <T> ExecuteRequest <T>(HttpWebRequest request)
            where T : class, new()
        {
            PowerBIApiResponse <T> result = new PowerBIApiResponse <T>();
            var response       = (HttpWebResponse)request.GetResponse();
            var responseStream = response.GetResponseStream();

            result.ResponseCode = response.StatusCode;
            using (StreamReader reader = new StreamReader(responseStream))
            {
                string returnedJson = reader.ReadToEnd();
                result.Data = Newtonsoft.Json.JsonConvert.DeserializeObject <T>(returnedJson);
                reader.Close();
            }
            return(result);
        }
예제 #2
0
        public PowerBIApiResponse <Entities.Reports> GetReports(string pGroupId = null)
        {
            string requestUrl = string.Empty;

            if (!string.IsNullOrEmpty(pGroupId))
            {
                requestUrl = string.Format("https://api.powerbi.com/v1.0/myorg/{0}/reports", pGroupId);
            }
            else
            {
                requestUrl = "https://api.powerbi.com/v1.0/myorg/reports";
            }
            var request = this.CreateHttpRequest(requestUrl, HttpMethod.Get);
            PowerBIApiResponse <Entities.Reports> objReports =
                ExecuteRequest <Entities.Reports>(request);

            return(objReports);
        }