Пример #1
0
        protected void getReportsButton_Click(object sender, EventArgs e)
        {
            string responseContent = string.Empty;

            //Configure reports request
            System.Net.WebRequest request = System.Net.WebRequest.Create(String.Format("{0}reports", baseUri)) as System.Net.HttpWebRequest;
            request.Method        = "GET";
            request.ContentLength = 0;
            request.Headers.Add("Authorization", String.Format("Bearer {0}", authResult.AccessToken));

            //Get reports response from request.GetResponse()
            using (var response = request.GetResponse() as System.Net.HttpWebResponse)
            {
                //Get reader from response stream
                using (var reader = new System.IO.StreamReader(response.GetResponseStream()))
                {
                    responseContent = reader.ReadToEnd();

                    //Deserialize JSON string
                    PBIReports PBIReports = JsonConvert.DeserializeObject <PBIReports>(responseContent);

                    tb_reportsResult.Text = string.Empty;
                    //Get each report
                    foreach (PBIReport rpt in PBIReports.value)
                    {
                        tb_reportsResult.Text += String.Format("{0}\t{1}\t{2}\n", rpt.id, rpt.name, rpt.embedUrl);
                    }
                }
            }
        }
Пример #2
0
        //Get a Report. In this sample, you get the first Report.
        protected void GetReport(int index)
        {
            //Configure Reports request
            System.Net.WebRequest request = System.Net.WebRequest.Create(
                String.Format("{0}/Reports",
                              baseUri)) as System.Net.HttpWebRequest;

            request.Method        = "GET";
            request.ContentLength = 0;
            request.Headers.Add("Authorization", String.Format("Bearer {0}", accessToken.Value));

            //Get Reports response from request.GetResponse()
            using (var response = request.GetResponse() as System.Net.HttpWebResponse)
            {
                //Get reader from response stream
                using (var reader = new System.IO.StreamReader(response.GetResponseStream()))
                {
                    //Deserialize JSON string
                    PBIReports Reports = JsonConvert.DeserializeObject <PBIReports>(reader.ReadToEnd());

                    //Sample assumes at least one Report.
                    //You could write an app that lists all Reports
                    if (Reports.value.Length > 0)
                    {
                        ReportEmbedUrl.Text = Reports.value[index].embedUrl;
                    }
                }
            }
        }
Пример #3
0
        protected void getReportsButton_Click(object sender, EventArgs e)
        {
            string responseContent = string.Empty;

            //Configure reports request
            System.Net.WebRequest request = System.Net.WebRequest.Create(String.Format("{0}reports", baseUri)) as System.Net.HttpWebRequest;
            request.Method        = "GET";
            request.ContentLength = 0;
            request.Headers.Add("Authorization", String.Format("Bearer {0}", authResult.AccessToken));

            //Get reports response from request.GetResponse()
            using (var response = request.GetResponse() as System.Net.HttpWebResponse)
            {
                //Get reader from response stream
                using (var reader = new System.IO.StreamReader(response.GetResponseStream()))
                {
                    responseContent = reader.ReadToEnd();

                    //Deserialize JSON string
                    PBIReports PBIReports = JsonConvert.DeserializeObject <PBIReports>(responseContent);

                    if (PBIReports != null)
                    {
                        var gridViewReport = PBIReports.value.Select(report => new {
                            id       = report.id,
                            name     = report.name,
                            embedUrl = report.embedUrl
                        });

                        this.GridView1.DataSource = gridViewReport;
                        this.GridView1.DataBind();
                    }
                }
            }
        }