<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Step 2 in Sample &amp;quot;Push dat to Azure by Adam Saxton :AcquireToken will acquire an Azure access token in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/107950#M3764</link>
    <description>&lt;P&gt;I've working on the sample "Push data into a dashboard" by Adam Saxton. In Step 2: Get an authentication access token code is provided to get authentication. The NuGet Package Microsoft.IdentityModel.Clients.ActiveDirectory is now updated to version 3.13.8 and I get an error on the codeline "string token = authContext.AcquireToken(resourceUri, clientID, new Uri(redirectUri)).AccessToken; : Severity&amp;nbsp;Code&amp;nbsp;Description&amp;nbsp;Project&amp;nbsp;File&amp;nbsp;Line&amp;nbsp;Suppression State&lt;BR /&gt;Error&amp;nbsp;CS1061&amp;nbsp;'AuthenticationContext' does not contain a definition for 'AcquireToken' and no extension method 'AcquireToken' accepting a first argument of type 'AuthenticationContext' could be found (are you missing a using directive or an assembly reference?)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone provide me with the correct code-statement to be used here ? I"ve tried a few attempts myself, but couldn't figure it out...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is much appriciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ruud&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 01 Jan 2017 11:07:21 GMT</pubDate>
    <dc:creator>RuudJeursen</dc:creator>
    <dc:date>2017-01-01T11:07:21Z</dc:date>
    <item>
      <title>Step 2 in Sample "Push dat to Azure by Adam Saxton :AcquireToken will acquire an Azure access token</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/107950#M3764</link>
      <description>&lt;P&gt;I've working on the sample "Push data into a dashboard" by Adam Saxton. In Step 2: Get an authentication access token code is provided to get authentication. The NuGet Package Microsoft.IdentityModel.Clients.ActiveDirectory is now updated to version 3.13.8 and I get an error on the codeline "string token = authContext.AcquireToken(resourceUri, clientID, new Uri(redirectUri)).AccessToken; : Severity&amp;nbsp;Code&amp;nbsp;Description&amp;nbsp;Project&amp;nbsp;File&amp;nbsp;Line&amp;nbsp;Suppression State&lt;BR /&gt;Error&amp;nbsp;CS1061&amp;nbsp;'AuthenticationContext' does not contain a definition for 'AcquireToken' and no extension method 'AcquireToken' accepting a first argument of type 'AuthenticationContext' could be found (are you missing a using directive or an assembly reference?)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone provide me with the correct code-statement to be used here ? I"ve tried a few attempts myself, but couldn't figure it out...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is much appriciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ruud&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Jan 2017 11:07:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/107950#M3764</guid>
      <dc:creator>RuudJeursen</dc:creator>
      <dc:date>2017-01-01T11:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: Step 2 in Sample "Push dat to Azure by Adam Saxton :AcquireToken will acquire an Azure acce</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/108067#M3765</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/11305"&gt;@RuudJeursen&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;In the sample, steps 2 is using&lt;/P&gt;
&lt;PRE&gt;Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory -Version 2.21.301221612&lt;/PRE&gt;
&lt;P&gt;In the newer &lt;A href="https://blogs.technet.microsoft.com/enterprisemobility/2016/05/18/adal-net-v3-reaches-ga/" target="_self"&gt;ADAL v3&lt;/A&gt;, try a new sample&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using Microsoft.IdentityModel.Clients.ActiveDirectory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication32
{
    class Program
    { 
        static void Main(string[] args)
        {
            string token =  GetToken();
            Console.WriteLine(token);             
            Console.ReadLine();
             
        }

        #region Get an authentication access token
        private  static string GetToken()
        {
            // TODO: Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory -Version 2.21.301221612
            // and add using Microsoft.IdentityModel.Clients.ActiveDirectory

            //The client id that Azure AD created when you registered your client app.
            string clientID = "3f756axxxxxxx3662e";

            //RedirectUri you used when you register your app.
            //For a client app, a redirect uri gives Azure AD more details on the application that it will authenticate.
            // You can use this redirect uri for your client app
            string redirectUri = "https://login.live.com/oauth20_desktop.srf";

            //Resource Uri for Power BI API
            string resourceUri = "https://analysis.windows.net/powerbi/api";

            //OAuth2 authority Uri
            string authorityUri = "https://login.windows.net/common/oauth2/authorize";

            //Get access token:
            // To call a Power BI REST operation, create an instance of AuthenticationContext and call AcquireToken
            // AuthenticationContext is part of the Active Directory Authentication Library NuGet package
            // To install the Active Directory Authentication Library NuGet package in Visual Studio,
            //  run "Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory" from the nuget Package Manager Console.

            // AcquireToken will acquire an Azure access token
            // Call AcquireToken to get an Azure token from Azure Active Directory token issuance endpoint
            AuthenticationContext authContext = new AuthenticationContext(authorityUri);

            //string token = authContext.AcquireToken(resourceUri, clientID, new Uri(redirectUri)).AccessToken;
&lt;STRONG&gt;
            return   authContext.AcquireTokenAsync(resourceUri, clientID, new Uri(redirectUri), new PlatformParameters(0)).Result.AccessToken;
            &lt;/STRONG&gt; 
            
             
        }

        #endregion
    }
}
&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Jan 2017 06:49:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/108067#M3765</guid>
      <dc:creator>Eric_Zhang</dc:creator>
      <dc:date>2017-01-02T06:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: Step 2 in Sample "Push dat to Azure by Adam Saxton :AcquireToken will acquire an Azure acce</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/108904#M3796</link>
      <description>&lt;P&gt;Thanks very much for your help! It worked !!&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jan 2017 11:22:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/108904#M3796</guid>
      <dc:creator>RuudJeursen</dc:creator>
      <dc:date>2017-01-04T11:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: Step 2 in Sample "Push dat to Azure by Adam Saxton :AcquireToken will acquire an Azure acce</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/113419#M3927</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got as far as the last step in this example: adding rows to the dataset.&lt;/P&gt;&lt;P&gt;Greated the token, created the dataset en got back the datasetID.&lt;/P&gt;&lt;P&gt;When adding the rows I got the error-message in Visual Studio on the code-line&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;var response = (HttpWebResponse)request.GetResponse();&lt;/PRE&gt;&lt;P&gt;:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;"An unhandled exception of type 'System.Net.WebException' occurred in System.dll&lt;/FONT&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;FONT color="#000000"&gt;Additional information: De externe server heeft een fout geretourneerd: (404) Niet gevonden."&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;FONT color="#000000"&gt;Can&amp;nbsp;someone help me out on this ?&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;FONT color="#000000"&gt;Console-screenshot&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;FONT color="#000000"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Console 14-1-2017 13-24-08.jpg" style="width: 200px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/26149i03FFE02189FA0943/image-size/small?v=v2&amp;amp;px=200" role="button" title="Console 14-1-2017 13-24-08.jpg" alt="Console 14-1-2017 13-24-08.jpg" /&gt;&lt;/span&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards, Ruud&lt;/P&gt;</description>
      <pubDate>Sat, 14 Jan 2017 12:50:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/113419#M3927</guid>
      <dc:creator>RuudJeursen</dc:creator>
      <dc:date>2017-01-14T12:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Step 2 in Sample "Push dat to Azure by Adam Saxton :AcquireToken will acquire an Azure acce</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/115767#M3991</link>
      <description>&lt;P&gt;Check the answer in your new post.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 09:35:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/115767#M3991</guid>
      <dc:creator>Eric_Zhang</dc:creator>
      <dc:date>2017-01-19T09:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: Step 2 in Sample "Push dat to Azure by Adam Saxton :AcquireToken will acquire an Azure acce</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/151756#M5133</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm stuck in Step 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's what I did.&lt;/P&gt;&lt;P&gt;Using Visual Studio 2017&lt;/P&gt;&lt;P&gt;Console App &amp;gt; .NET Framework 4.5 &amp;gt; (.Net Framework) Visual C#&amp;nbsp;&lt;/P&gt;&lt;P&gt;Iin Package Manager Console , entered this:&amp;nbsp;Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory -Version 2.21.301221612&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Entered this code in Program.cs&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;using Microsoft.IdentityModel.Clients.ActiveDirectory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication32
{
    class Program
    { 
        static void Main(string[] args)
        {
            string token =  GetToken();
            Console.WriteLine(token);             
            Console.ReadLine();
             
        }

        #region Get an authentication access token
        private  static string GetToken()
        {
            // TODO: Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory -Version 2.21.301221612
            // and add using Microsoft.IdentityModel.Clients.ActiveDirectory

            //The client id that Azure AD created when you registered your client app.
            string clientID = "f57471a3-066b-47a4-92b5-30177196d891";

            //RedirectUri you used when you register your app.
            //For a client app, a redirect uri gives Azure AD more details on the application that it will authenticate.
            // You can use this redirect uri for your client app
            string redirectUri = "https://login.live.com/oauth20_desktop.srf";

            //Resource Uri for Power BI API
            string resourceUri = "https://analysis.windows.net/powerbi/api";

            //OAuth2 authority Uri
            string authorityUri = "https://login.windows.net/common/oauth2/authorize";

            //Get access token:
            // To call a Power BI REST operation, create an instance of AuthenticationContext and call AcquireToken
            // AuthenticationContext is part of the Active Directory Authentication Library NuGet package
            // To install the Active Directory Authentication Library NuGet package in Visual Studio,
            //  run "Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory" from the nuget Package Manager Console.

            // AcquireToken will acquire an Azure access token
            // Call AcquireToken to get an Azure token from Azure Active Directory token issuance endpoint
            AuthenticationContext authContext = new AuthenticationContext(authorityUri);

            //string token = authContext.AcquireToken(resourceUri, clientID, new Uri(redirectUri)).AccessToken;
&lt;STRONG&gt;            return   authContext.AcquireTokenAsync(resourceUri, clientID, new Uri(redirectUri), new PlatformParameters(0)).Result.AccessToken;
            &lt;/STRONG&gt; 
            
             
        }

        #endregion
    }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Got this when trying to debug: &lt;EM&gt;ConsoleApp1.exe is missing. Please build the probject and retry, or set the OutPath and AssemblyName properties appropriately to point at the correct location for target assembly.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And in error list:&lt;/P&gt;&lt;P&gt;Code - CS0246&lt;/P&gt;&lt;P&gt;Description - &amp;nbsp;The type or namespace name 'PlatformParameters' could not be found ( are &amp;nbsp;you missing a using directive or an assembly reference)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By the way, I'm a complete noob to visual studio. I've just been trying to push data to Power BI with no success.&lt;/P&gt;&lt;P&gt;I'm using Excel 2013 Standard - which doesnt come with Power Pivot.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 02:18:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/151756#M5133</guid>
      <dc:creator>danextian</dc:creator>
      <dc:date>2017-03-31T02:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: Step 2 in Sample "Push dat to Azure by Adam Saxton :AcquireToken will acquire an Azure acce</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/151967#M5135</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below the code of all the steps. This is slightly different from the example and was partly given by the moderator.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this works for you: don't forget to enter your Azure AD in this code-lines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ruud.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;using Microsoft.IdentityModel.Clients.ActiveDirectory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.IO;
using Newtonsoft.Json;



namespace ConsoleApplication_PowerBI_02
{
    class Program
    {

        private static string token = string.Empty;

        static void Main(string[] args)
        {
            string token = GetToken();
            Console.WriteLine(token);
            //Console.ReadLine();

            //Create a dataset in a Power BI dashboard
            CreateDataset();

            //Get a dataset to add rows into a Power BI table
            string datasetId = GetDataset();

            //Add rows to a Power BI table
            AddRows(datasetId, "Product");


        }

        #region Get an authentication access token
        private static string GetToken()
        {
            // TODO: Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory -Version 2.21.301221612
            // and add using Microsoft.IdentityModel.Clients.ActiveDirectory

            //The client id that Azure AD created when you registered your client app.
            string clientID = "ENTER YOUR AZURE AD CODE HERE";

            //RedirectUri you used when you register your app.
            //For a client app, a redirect uri gives Azure AD more details on the application that it will authenticate.
            // You can use this redirect uri for your client app
            string redirectUri = "https://login.live.com/oauth20_desktop.srf";

            //Resource Uri for Power BI API
            string resourceUri = "https://analysis.windows.net/powerbi/api";

            //OAuth2 authority Uri
            string authorityUri = "https://login.windows.net/common/oauth2/authorize";

            //Get access token:
            // To call a Power BI REST operation, create an instance of AuthenticationContext and call AcquireToken
            // AuthenticationContext is part of the Active Directory Authentication Library NuGet package
            // To install the Active Directory Authentication Library NuGet package in Visual Studio,
            //  run "Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory" from the nuget Package Manager Console.

            // AcquireToken will acquire an Azure access token
            // Call AcquireToken to get an Azure token from Azure Active Directory token issuance endpoint
            AuthenticationContext authContext = new AuthenticationContext(authorityUri);

            //string token = authContext.AcquireToken(resourceUri, clientID, new Uri(redirectUri)).AccessToken;

            return authContext.AcquireTokenAsync(resourceUri, clientID, new Uri(redirectUri), new PlatformParameters(0)).Result.AccessToken;

        }

        #endregion

        #region Create a dataset in a Power BI dashboard
        private static void CreateDataset()
        {
            //TODO: Add using System.Net and using System.IO

            //Push data into a Power BI dashboard

            string powerBIDatasetsApiUrl = "https://api.powerbi.com/v1.0/myorg/datasets";
            //POST web request to create a dataset.
            //To create a Dataset in a group, use the Groups uri: https://api.PowerBI.com/v1.0/myorg/groups/{group_id}/datasets
            HttpWebRequest request = System.Net.WebRequest.Create(powerBIDatasetsApiUrl) as System.Net.HttpWebRequest;
            request.KeepAlive = true;
            request.Method = "POST";
            request.ContentLength = 0;
            request.ContentType = "application/json";

            //Add token to the request header
            request.Headers.Add("Authorization", String.Format("Bearer {0}", GetToken()));

            //Create dataset JSON for POST request
            string datasetJson = "{\"name\": \"SalesMarketing\", \"tables\": " +
                "[{\"name\": \"Product\", \"columns\": " +
                "[{ \"name\": \"ProductID\", \"dataType\": \"Int64\"}, " +
                "{ \"name\": \"Name\", \"dataType\": \"string\"}, " +
                "{ \"name\": \"Category\", \"dataType\": \"string\"}," +
                "{ \"name\": \"IsCompete\", \"dataType\": \"bool\"}," +
                "{ \"name\": \"ManufacturedOn\", \"dataType\": \"DateTime\"}" +
                "]}]}";

            //POST web request
            byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(datasetJson);
            request.ContentLength = byteArray.Length;

            //Write JSON byte[] into a Stream
            using (Stream writer = request.GetRequestStream())
            {
                writer.Write(byteArray, 0, byteArray.Length);

                var response = (HttpWebResponse)request.GetResponse();

                Console.WriteLine(string.Format("Dataset {0}", response.StatusCode.ToString()));

                //Console.ReadLine();
            }
        }
        #endregion

        #region Get a dataset to add rows into a Power BI table
        private static string GetDataset()
        {
            string powerBIDatasetsApiUrl = "https://api.powerbi.com/v1.0/myorg/datasets";
            //POST web request to create a dataset.
            //To create a Dataset in a group, use the Groups uri: https://api.PowerBI.com/v1.0/myorg/groups/{group_id}/datasets
            HttpWebRequest request = System.Net.WebRequest.Create(powerBIDatasetsApiUrl) as System.Net.HttpWebRequest;
            request.KeepAlive = true;
            request.Method = "GET";
            request.ContentLength = 0;
            request.ContentType = "application/json";

            //Add token to the request header
            request.Headers.Add("Authorization", String.Format("Bearer {0}", GetToken()));

            string datasetId = string.Empty;
            //Get HttpWebResponse from GET request
            using (HttpWebResponse httpResponse = request.GetResponse() as System.Net.HttpWebResponse)
            {
                //Get StreamReader that holds the response stream
                using (StreamReader reader = new System.IO.StreamReader(httpResponse.GetResponseStream()))
                {
                    string responseContent = reader.ReadToEnd();

                    //TODO: Install NuGet Newtonsoft.Json package: Install-Package Newtonsoft.Json
                    //and add using Newtonsoft.Json
                    var results = JsonConvert.DeserializeObject&amp;lt;dynamic&amp;gt;(responseContent);

                    //Get the first id
                    //datasetId = results["value"][0]["id"];

                    //Get the first id
                    //datasetId = results["value"][0]["id"];

                    var datasets = results["value"];

                    foreach (var ds in datasets)
                    {

                        //return the id of the first salesmarketing dataset
                        if (ds["name"] == "SalesMarketing")
                        {
                            datasetId = ds["id"];
                            break;
                        }
                    }


                    Console.WriteLine(String.Format("Dataset ID: {0}", datasetId));
                    //Console.ReadLine();

                    return datasetId;
                }
            }
        }
        #endregion

        #region Add rows to a Power BI table
        private static void AddRows(string datasetId, string tableName)
        {
            string powerBIApiAddRowsUrl = String.Format("https://api.powerbi.com/v1.0/myorg/datasets/{0}/tables/{1}/rows", datasetId, tableName);

            //POST web request to add rows.
            //To add rows to a dataset in a group, use the Groups uri: https://api.powerbi.com/v1.0/myorg/groups/{group_id}/datasets/{dataset_id}/tables/{table_name}/rows
            //Change request method to "POST"
            HttpWebRequest request = System.Net.WebRequest.Create(powerBIApiAddRowsUrl) as System.Net.HttpWebRequest;
            request.KeepAlive = true;
            request.Method = "POST";
            request.ContentLength = 0;
            request.ContentType = "application/json";

            //Add token to the request header
            request.Headers.Add("Authorization", String.Format("Bearer {0}", GetToken()));

            //JSON content for product row
            string rowsJson = "{\"rows\":" +
                "[{\"ProductID\":1,\"Name\":\"Adjustable Race\",\"Category\":\"Components\",\"IsCompete\":true,\"ManufacturedOn\":\"07/30/2014\"}," +
                "{\"ProductID\":2,\"Name\":\"LL Crankarm\",\"Category\":\"Components\",\"IsCompete\":true,\"ManufacturedOn\":\"07/30/2014\"}," +
                "{\"ProductID\":3,\"Name\":\"HL Mountain Frame - Silver\",\"Category\":\"Bikes\",\"IsCompete\":true,\"ManufacturedOn\":\"07/30/2014\"}]}";

            //POST web request
            byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(rowsJson);
            request.ContentLength = byteArray.Length;

            //Write JSON byte[] into a Stream
            using (Stream writer = request.GetRequestStream())
            {
                writer.Write(byteArray, 0, byteArray.Length);

                var response = (HttpWebResponse)request.GetResponse();

                Console.WriteLine("Rows Added");

                //Console.ReadLine();
            }
        }

        #endregion

    }
}


&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 Mar 2017 09:23:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/151967#M5135</guid>
      <dc:creator>RuudJeursen</dc:creator>
      <dc:date>2017-03-31T09:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: Step 2 in Sample "Push dat to Azure by Adam Saxton :AcquireToken will acquire an Azure acce</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/224246#M7089</link>
      <description>&lt;P&gt;Have you figured this out? I'm getting the same error.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2017 22:06:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/224246#M7089</guid>
      <dc:creator>acp8888</dc:creator>
      <dc:date>2017-08-02T22:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: Step 2 in Sample "Push dat to Azure by Adam Saxton :AcquireToken will acquire an Azure acce</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/353504#M10517</link>
      <description>Did you figure it out? I am also facing the same issue.</description>
      <pubDate>Wed, 07 Feb 2018 10:58:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/353504#M10517</guid>
      <dc:creator>kritika_goel</dc:creator>
      <dc:date>2018-02-07T10:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: Step 2 in Sample "Push dat to Azure by Adam Saxton :AcquireToken will acquire an Azure acce</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/354340#M10535</link>
      <description>&lt;P&gt;Try refreshing your pbix manually.&amp;nbsp; If doing so returns an error which do not allow the Power&amp;nbsp; Query data to be loaded into the model, you'll need to fix that. Mine was due to relationship error as one of the columns that&amp;nbsp;was supposed to have unique values suddenly contained duplicates. Relationship requires one of the columns to have unique values.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 07:06:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Step-2-in-Sample-quot-Push-dat-to-Azure-by-Adam-Saxton/m-p/354340#M10535</guid>
      <dc:creator>danextian</dc:creator>
      <dc:date>2018-02-08T07:06:06Z</dc:date>
    </item>
  </channel>
</rss>

