0
votes

Has anyone tried this? The API as defined here: https://msdn.microsoft.com/en-us/library/mt203562.aspx is vague. It suggests the following structure for SSAS on premise:

{
   "name":"SalesMarketing",
   "defaultMode":"AsOnPrem",
   "tables": [],
   "datasources":[
      {
         "name":"SalesMarketing",
         "connectionString":"Data Source=asazure://westcentralus.asazure.windows.net/mypowerbi;Initial Catalog=SalesMarketing;Cube=Model"
      }
   ]
}

On premise SSAS connections must be done through a Gateway and a datasource. I have gateway and datasource working with a Power Bi Report. However, I cannot create a dataset from c# using their example. I always get (400) Bad Request. This is typical error for just about anything on the PBI service. There are no clues as to what the error is. I tried to capture the calls to the the service using the "Get Data" button on powerbi.com but the queries did not make sense and did not match API. Any ideas on what the structure should contain for a gateway datasource?

1

1 Answers

0
votes

After a lot of trial and error I solved it:

string dataset = $@"{{
    ""name"":""{dataSetName}"",
    ""defaultMode"":""AsOnPrem"",
    ""tables"": [],
    ""datasources"":[
        {{
        ""name"":""{dataSourceName}"",
        ""connectionString"":""Provider=MSOLAP.5;Data Source={server};Initial Catalog={ssasTabularModelName};Cube=Model;""
        }} ]
}}

The key is in the connection string format.