gbrueckl / PowerBI.API.Client

A C# wrapper for the Power BI REST API which allows you to easily integrate the Power BI API into your C# application.
MIT License
39 stars 14 forks source link

Syncing to previously pushed dataset does not restore columns #11

Closed abstractspoon closed 5 years ago

abstractspoon commented 5 years ago

Hi Gerhard

After creating a dataset using the Sample_PushDataset, and then attempting to sync to it using the following function, the 'dataset' object is populated with the table that was created, but the table does not have any columns...

  private static void Test_SyncDataset(PBIAPIClient pbic)
  {
     string datasetName = "MyPushDataset";

     PBIDataset dataset = new PBIDataset(datasetName, PBIDefaultMode.Push);
     dataset.ParentPowerBIAPI = pbic;

     Console.WriteLine("Syncing to PowerBI Service ... ");
     dataset.SyncFromPowerBI(); // check if a Dataset with the same ID or Name already exists in the PowerBI-Service
     Console.WriteLine("Done!");
  }
gbrueckl commented 5 years ago

yes, this is "by design" to be more precise, the API does not offer a function to retrieve the metadata of a dataset/table/column once it was published If you call the Get Dataset API, you will only receive high-level information but no details about tables or columns: https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/getdatasetbyid

gbrueckl commented 5 years ago

just checked the API again and it seems that a new functionality was added to also retrieve metadata for Push-datasets: https://docs.microsoft.com/en-us/rest/api/power-bi/pushdatasets/datasets_gettables will add this functionality in the near future and update you here!

abstractspoon commented 5 years ago

Many thx Gerhard.

new functionality was added to also retrieve metadata for Push-datasets:

TBH, I thought you were already supporting this:

        public string PBITable.ApiURL
        {
            get
            {
                if (ParentGroup == null)
                    return string.Format("/v1.0/myorg/datasets/{0}/tables/{1}", ParentDataset.Id, Name);
                else
                    return string.Format("/v1.0/myorg/groups/{0}/datasets/{1}/tables/{2}", ParentGroup.Id, ParentDataset.Id, Name);
            }
        }
abstractspoon commented 5 years ago

ps. I'm actually excited by the possibility of integrating your library into my app, hence my pushiness :)

gbrueckl commented 5 years ago

I just ran some tests and even though the docs state that the call to the tables API (https://docs.microsoft.com/en-us/rest/api/power-bi/pushdatasets/datasets_gettables) also returns columns and measures, it in fact only returns the name of the table

the JSON that I get returned is as follows:

{
  "@odata.context":"http://wabi-us-north-central-redirect.analysis.windows.net/v1.0/myorg/$metadata#tables","value":[
    {
      "name":"MySalesTable"
    }
  ]
}

once this is working correctly in the REST API, it will also return the columns, measures, etc. in the C# objects