1
votes

Manage to create datasets when following the Sample push data into Dashboard for power BI, but now facing a Server Access issue. As at run time i get the following exception : The Remote server returned an error: (404) Not found. Has anyone faced the same Problem or could help get it solve?

    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);

      //the above Url is the one provided for contacting the Server

          using (Stream writer = request.GetRequestStream())
        {
            writer.Write(byteArray, 0, byteArray.Length);

            var response = (HttpWebResponse)request.GetResponse();

            Console.WriteLine("Rows Added");

            Console.ReadLine();
        }

    }
 }
1

1 Answers

1
votes

While following the walkthrough instruction for the push data into power BI, for the GetDataset method one should dynamically get the DatasetID instead of using static indexing. In case there is more than one dataset in the power BI dasboard. here is how with the help of a colleague we manage to solve the issue.

                datasetId = results["value"][0]["id"];

Replacing the above line from the GetDataset method from the provided walkthrough, by the bellow Code would set the correct datasetID in the AddRows method. Therefore no more Exception.

                foreach (Newtonsoft.Json.Linq.JObject j in (results["value"] as Newtonsoft.Json.Linq.JArray))
                {
                    if (j.Value<string>("name") == "SalesMarketing")
                    {
                        datasetId = j.Value<string>("id");
                    }
                }