//Groups: The Add Rows operation adds Rows to a Table in a Dataset in a Group. //POST https://api.powerbi.com/v1.0/myorg/groups/{group_id}/datasets/{dataset_id}/tables/{table_name}/rows //Add Rows operation: https://msdn.microsoft.com/en-US/library/mt203561.aspx static void AddRows(string groupId, string datasetId, string tableName) { //In a production application, use more specific exception handling. try { HttpWebRequest request = DatasetRequest(String.Format("{0}/groups/{1}/datasets/{2}/tables/{3}/rows", datasetsUri, groupId, datasetId, tableName), "POST", AccessToken()); //Create a list of Product List <Product> products = new List <Product> { new Product { ProductID = 1, Name = "Adjustable Race", Category = "Components", IsCompete = true, ManufacturedOn = new DateTime(2014, 7, 30) }, new Product { ProductID = 2, Name = "LL Crankarm", Category = "Components", IsCompete = true, ManufacturedOn = new DateTime(2014, 7, 30) }, new Product { ProductID = 3, Name = "HL Mountain Frame - Silver", Category = "Bikes", IsCompete = true, ManufacturedOn = new DateTime(2014, 7, 30) }, }; //POST request using the json from a list of Product //NOTE: Posting rows to a model that is not created through the Power BI API is not currently supported. // Please create a dataset by posting it through the API following the instructions on http://dev.powerbi.com. Console.WriteLine(PostRequest(request, products.ToJson(JavaScriptConverter <Product> .GetSerializer()))); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static void AddRowsInit(string datasetId, string tableName) { //In a production application, use more specific exception handling. try { HttpWebRequest request = DatasetRequest(String.Format("{0}/datasets/{1}/tables/{2}/rows", datasetsUri, datasetId, tableName), "POST", AccessToken()); //Create a list of Product List <Message> messages = new List <Message>(); int destination = 0; for (int i = 6; i < 15; i++) { destination += 5; messages.Add( new Message() { Hour = string.Format("{0}:00", ("0" + i.ToString()).Substring(("0" + i.ToString()).Length - 2, 2)), Value = destination, Destination = destination } ); } //POST request using the json from a list of Product //NOTE: Posting rows to a model that is not created through the Power BI API is not currently supported. // Please create a dataset by posting it through the API following the instructions on http://dev.powerbi.com. Console.WriteLine(PostRequest(request, messages.ToJson(JavaScriptConverter <Message> .GetSerializer()))); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static void AddClassRows() { //Get dataset id from a table name string datasetId = GetAllDatasets().Datasets(datasetName).First()["id"].ToString(); //In a production application, use more specific exception handling. try { HttpWebRequest request = DatasetRequest(String.Format("{0}/{1}/tables/{2}/rows", datasetsUri, datasetId, tableName), "POST", AccessToken); //Create a new fuelup Fuelup fuelup = ReadFuelupFromConsole(); Console.WriteLine(fuelup.ToJson(JavaScriptConverter <Fuelup> .GetSerializer())); //POST request using the json from a list of Product //NOTE: Posting rows to a model that is not created through the Power BI API is not currently supported. // Please create a dataset by posting it through the API following the instructions on http://dev.powerbi.com. Console.WriteLine(PostRequest(request, fuelup.ToJson(JavaScriptConverter <Fuelup> .GetSerializer()))); } catch (Exception ex) { Console.WriteLine(ex.Message); } }