Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Dear Techies,
I have to import PBIX files to multiple workspaces. Each workspace is meant to point diffrent Analysis Services DB and we have on premises gateway for this instance. The Problem is when I try to Import PBIX files using Import API. Connection string is set same across all the workspaces. Which should not be the case, PBIX file should point to its respective Analysis Services DB in a workspace.
I am trying to use SetAllConnections API to update the connection string. But I am getting 400 bad request exception, please refer my code below
Am I missing anything here? I don't have much coding knowledge please help me out
private static void UpdateConnection(string DatasetID)
{
string powerBIDatasetsApiUrl = String.Format(" https://api.PowerBI.com/v1.0/myorg/datasets/{0}/Default.SetAllConnections", DatasetID);
HttpWebRequest request = System.Net.WebRequest.Create(powerBIDatasetsApiUrl) asSystem.Net.HttpWebRequest;
request.KeepAlive = true;
request.Method = "POST";
request.ContentLength = 0;
request.ContentType = "application/json";
//Add token to the request header
request.Headers.Add("Authorization", String.Format("Bearer {0}", token));
string updateJSON = "{\"connectionString\":\"data source=DEVXXXX;initial catalog=XXX;Cube=Occupancy;persist security info=False\",\"ConnectionType\":\"analysisServicesDatabaseLive\"}";
//POST web request
byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(updateJSON);
request.ContentLength = byteArray.Length;
//Write JSON byte[] into a Stream
using (Stream writer = request.GetRequestStream())
{
writer.Write(byteArray, 0, byteArray.Length);
var response = (HttpWebResponse)request.GetResponse();
Console.ReadLine();
}
}
Please post the sample code
Thanks in Advance,
Latheesh
I don't think you can call the API for a dataset connecting to Analysis Service. Per my test, that API only works for dataset in direct query mode, anyhow live connction for AS is not treated as direct query mode.
For quick testing purpose, you can reference this thread.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
6 | |
4 | |
2 | |
2 |
User | Count |
---|---|
4 | |
3 | |
3 | |
3 | |
3 |