<?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 Re: Datasets.Extensions.PostRowsAsync() - param documentation? in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Datasets-Extensions-PostRowsAsync-param-documentation/m-p/503924#M15492</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Dandy72,&amp;nbsp;&lt;/P&gt;&lt;P&gt;While reading the comments I am exactly in same situation like you explained below. Were you able to solve the problem ? Please share your idea if you have implemented according to your workflow?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 31 Aug 2018 01:08:57 GMT</pubDate>
    <dc:creator>rajusharma</dc:creator>
    <dc:date>2018-08-31T01:08:57Z</dc:date>
    <item>
      <title>Datasets.Extensions.PostRowsAsync() - param documentation?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Datasets-Extensions-PostRowsAsync-param-documentation/m-p/203967#M6516</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to use PostRowsAsync(), documented here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.powerbi.api.v1.datasetsextensions.postrowsasync?view=powerbiapi-1.1.10" target="_blank"&gt;https://docs.microsoft.com/en-us/dotnet/api/microsoft.powerbi.api.v1.datasetsextensions.postrowsasync?view=powerbiapi-1.1.10&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's got a "requestMessage" parameter of type "Object", and that's all the documentation there is to it.&amp;nbsp; While it can be inferred this is part of an HTTP request, I have no idea with it can/needs to be set to, or its format, encoding, etc.&amp;nbsp; I also can't find any sample using this library, so I'm left guessing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've used many other classes/functions from this library and I've generally been able to make good use of it based on a few samples on GitHub, but none I've come across use this particular function (or its non-async version, PostRow()).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm making the assumption that&amp;nbsp;the link above is part of the documentation for the code at:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Microsoft/PowerBI-CSharp" target="_blank"&gt;https://github.com/Microsoft/PowerBI-CSharp&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Digging into that source, I can see PostRowsAsync() invokes IDatasets.PostRowsWithHttpMessagesAsync().&amp;nbsp; In turn, I can see the function signature defined in:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Microsoft/PowerBI-CSharp/blob/master/sdk/PowerBI.Api/Source/V1/IDatasets.cs" target="_blank"&gt;https://github.com/Microsoft/PowerBI-CSharp/blob/master/sdk/PowerBI.Api/Source/V1/IDatasets.cs&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...but no code showing me what the library is internally doing with this parameter.&amp;nbsp; The parameter comments in this file shed very little extra light on "requestMessage", simply stating it's "the headers that will be added to request", which isn't terribly handy as I still don't know what's expected from those headers (and again, format, encoding etc).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Grasping at straws, I did find the implementation for PostRowsWithHttpMesagseAsync() inside Datasets.cs under the **V2** folder (not V1):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Microsoft/PowerBI-CSharp/blob/master/sdk/PowerBI.Api/Source/V2/Datasets.cs" target="_blank"&gt;https://github.com/Microsoft/PowerBI-CSharp/blob/master/sdk/PowerBI.Api/Source/V2/Datasets.cs&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code starting at around line 429 shows requestMessage is assumed to be convertable into a JSON string and then serialized (if I'm reading this right), but again, I'm not terribly confident of what should be passed in.&amp;nbsp; I've tried a raw JSON string based on samples that&amp;nbsp;invoke the REST API directly to add rows to a dataset (rather than using this library), but the errors I've gotten back from my trials and experiments aren't really indicating whether my parameter is valid or not; it seems like I've probably got other errors to deal with *regardless* of what I pass in (I get the same errors even if I provide null--so the code is probably not getting far enough to even start looking at the param).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finally (and I realize I'm all over the place here)...the content of "Power BI Azure Embedded Readme.md" at:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Microsoft/PowerBI-CSharp" target="_blank"&gt;https://github.com/Microsoft/PowerBI-CSharp&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...starts with a comment saying this library is now being deprecated in favor of the "...One Power BI API using powerbi.com".&amp;nbsp; My (very rough) understanding is that there's multiple SDKs that are being merged, which sounds to me like it's probably a good thing, but I now have no idea what the replacement for this library is (if there even is one at this point in time).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Should I even continue trying to get this parameter figured out?&amp;nbsp; If not,&amp;nbsp;what's the replacement for this now-deprecated library?&amp;nbsp; Should I abandon the whole thing and instead go directly to the REST API?&amp;nbsp; I'd hate to have to&amp;nbsp;resort to that,&amp;nbsp;as this is about the last thing I still needed to figure out before my project has all the basic required components completed, and the library's a rather nice wrapper around the raw REST API.&amp;nbsp; But if it's being abandoned, I need an alternative no matter what...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any guidance?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2017 20:25:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Datasets-Extensions-PostRowsAsync-param-documentation/m-p/203967#M6516</guid>
      <dc:creator>dandy72</dc:creator>
      <dc:date>2017-06-29T20:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: Datasets.Extensions.PostRowsAsync() - param documentation?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Datasets-Extensions-PostRowsAsync-param-documentation/m-p/206480#M6554</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/34624"&gt;@dandy72&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See a demo which works in my test.&lt;/P&gt;
&lt;P&gt;By the way, there's no replacement for the SDK, as the collectionname and workspaceid are the concepts in the being deprecated Power BI Embedded. The new "&lt;A href="https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-embedding/#embedding-with-non-power-bi-users" target="_self"&gt;embedding-with-non-power-bi-users&lt;/A&gt;" is embeding reports from Power BI Service instead of Azure PBI workspace.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.PowerBI.Api.V1;
using Microsoft.Rest;
using Microsoft.PowerBI.Api.V1.Models;

namespace ConsoleApplication39
{
    class Program
    {

        static string accesskey = "KJixsmmw+Ncxxxxx23xxxxxxcaOIFr6a2vmQ==";
        static string workspaceCollectionName = "cisxxxxexo";
        static string workspaceId = "79c71931-dexxxxa3cxxxd2192fe0b";
        static void Main(string[] args)
        {

            var credentials = new TokenCredentials(accesskey, "AppKey");

            // Instantiate your Power BI client passing in the required credentials
            var client = new PowerBIClient(credentials);

            // Override the api endpoint base URL.  Default value is https://api.powerbi.com
            client.BaseUri = new Uri("https://api.powerbi.com"); 

            //create a dataset and get datasetkey
            string datasetID =  CreateDatasets(workspaceCollectionName, workspaceId,client);

            string data = @"{  ""rows"":  
                                [
                                    { ""id"": 1, ""name"": ""Tom""},                                
                                    { ""id"": 2, ""name"": ""Jerry""}
                                ]
                            }";

           &lt;FONT size="4"&gt;&lt;STRONG&gt; object dataObj = Newtonsoft.Json.JsonConvert.DeserializeObject&amp;lt;Object&amp;gt;(data.ToString());
&lt;/STRONG&gt;&lt;/FONT&gt;
            PostRows(workspaceCollectionName,workspaceId,datasetID,"testtable", &lt;STRONG&gt;&lt;FONT size="4"&gt;dataObj&lt;/FONT&gt;&lt;/STRONG&gt;, client); 
             
        }


        static   void PostRows(string workspaceCollectionName, string workspaceId, string datasetid, string tableName, object datajson, PowerBIClient client )
        {
              //public static object PostRows(this IDatasets operations, string collectionName, string workspaceId, string datasetKey, string tableName, object requestMessage);
               var response =   client.Datasets.PostRows(workspaceCollectionName, workspaceId, datasetid, tableName,datajson);


        }

        static string CreateDatasets(string workspaceCollectionName, string workspaceId, PowerBIClient client)
        {
              
            Dataset ds = new Dataset();
                ds.Name = "testdataset";
                Table table1 = new Table();
                table1.Name = "testTable";
                

                Column column1 = new Column("id","Int64");
                Column column2 = new Column("name", "string");

                table1.Columns = new List&amp;lt;Column&amp;gt;() { column1, column2 }; 

                ds.Tables = new List&amp;lt;Table&amp;gt;() { table1}; 

                var response =   client.Datasets.PostDataset(workspaceCollectionName, workspaceId, ds);

                dynamic obj = Newtonsoft.Json.JsonConvert.DeserializeObject&amp;lt;Object&amp;gt;(response.ToString());
                return obj["id"].ToString(); 
        }

       

    }
}
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 10:16:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Datasets-Extensions-PostRowsAsync-param-documentation/m-p/206480#M6554</guid>
      <dc:creator>Eric_Zhang</dc:creator>
      <dc:date>2017-07-05T10:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: Datasets.Extensions.PostRowsAsync() - param documentation?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Datasets-Extensions-PostRowsAsync-param-documentation/m-p/206749#M6557</link>
      <description>&lt;P&gt;Thanks, this is exactly what I needed.&amp;nbsp; I should be able to complete&amp;nbsp;my project with this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm still not 100% clear on the distinctions between what's available right now (and moving forward), so once I get a bit of downtime, I'll try to figure it out and redo those parts of my project based on what should be the most appropriate in the longer term.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 18:11:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Datasets-Extensions-PostRowsAsync-param-documentation/m-p/206749#M6557</guid>
      <dc:creator>dandy72</dc:creator>
      <dc:date>2017-07-05T18:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: Datasets.Extensions.PostRowsAsync() - param documentation?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Datasets-Extensions-PostRowsAsync-param-documentation/m-p/208004#M6576</link>
      <description>&lt;P&gt;Hmmm...I suspect that, technically speaking this is exactly the answer to the question that I asked - but ultimately I'm running into something else that I think will force me to rethink my approach.&amp;nbsp; I'm running into this "Data [dataset id] is not Push API dataset" error that others have reported.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My understanding is that you can't add rows to a dataset that exists in the service when this dataset originates from a .pbix file that was uploaded.&amp;nbsp; If you create a dataset with the REST API, adding rows works, but for a dataset coming from a .pbix, it'll result in this "...not Push API dataset" error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used the desktop version of Power BI to create&amp;nbsp;my dataset, and some reports.&amp;nbsp; That got saved in a local .pbix file.&amp;nbsp; I then need to upload the whole thing, and update the data on a regular basis.&amp;nbsp; While I could create the dataset from scratch through the REST API, it's not clear to me how I could get the locally-created reports uploaded on their own, if they have to be separated from the dataset--and then the next problem would be to somehow link the reports with the dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've looked at getting my local&amp;nbsp;.pbix file refreshed programmatically (and then re-uploading the whole thing, after deleting anything that might already have been uploaded previously), but it looks like there's no API to do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What's the approach people take to do this sort of thing?&amp;nbsp; Seems to me the end goal is pretty simple:&amp;nbsp; A local .pbix defines reports, I want them uploaded to the service, and I want to programmatically pump new data into the dataset on a regular basis.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2017 14:19:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Datasets-Extensions-PostRowsAsync-param-documentation/m-p/208004#M6576</guid>
      <dc:creator>dandy72</dc:creator>
      <dc:date>2017-07-07T14:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: Datasets.Extensions.PostRowsAsync() - param documentation?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Datasets-Extensions-PostRowsAsync-param-documentation/m-p/479923#M14717</link>
      <description>&lt;P&gt;Over a year after the original post and there are still no comprehensive examples of API V2 async methods anywhere that I can find. Bad.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Aug 2018 12:49:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Datasets-Extensions-PostRowsAsync-param-documentation/m-p/479923#M14717</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-08-03T12:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: Datasets.Extensions.PostRowsAsync() - param documentation?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Datasets-Extensions-PostRowsAsync-param-documentation/m-p/503924#M15492</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Dandy72,&amp;nbsp;&lt;/P&gt;&lt;P&gt;While reading the comments I am exactly in same situation like you explained below. Were you able to solve the problem ? Please share your idea if you have implemented according to your workflow?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 01:08:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Datasets-Extensions-PostRowsAsync-param-documentation/m-p/503924#M15492</guid>
      <dc:creator>rajusharma</dc:creator>
      <dc:date>2018-08-31T01:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: Datasets.Extensions.PostRowsAsync() - param documentation?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Datasets-Extensions-PostRowsAsync-param-documentation/m-p/504209#M15500</link>
      <description>&lt;P&gt;This works, assuming you have the ID of the PowerBI dataset you're updating, the table name in the dataset, and your auth token:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;       public async Task&amp;lt;object&amp;gt; AddRowsToTableAsync(string datasetId, string tableName, object rows, string token)
        {
            var tokenCredentials = new TokenCredentials(token, "Bearer");
            var ret = new object();
            using (var c = new PowerBIClient(new Uri(PowerBIDatasetsApiUrl), tokenCredentials))
            {
               ret = await c.Datasets.PostRowsAsync(datasetId, tableName, rows);
            }
    
            return ret;
        }&lt;/PRE&gt;&lt;P&gt;Where for example 'rows' is a List&amp;lt;SerializableMyDataRow&amp;gt;, and SerializableMyDataRow is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public class SerializableMyDataRow
{
    [JsonProperty("Account")]
    public string Account { get; set; }

    [JsonProperty("Reference")]
    public string Reference { get; set; }

    [JsonProperty("Value")]
    public decimal Value { get; set; }

}&lt;/PRE&gt;&lt;P&gt;The properties there match the column names and types in the PowerBI table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 08:06:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Datasets-Extensions-PostRowsAsync-param-documentation/m-p/504209#M15500</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-08-31T08:06:02Z</dc:date>
    </item>
  </channel>
</rss>

