Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
Dear Techies,
I was successfully able to upload PBIX files to PBI Service using Import API. Now, I am trying to update the connection string using SetAllConnections API. The dataset that I am trying to update is using SQL Server as source and DirectQuery mode
Below is my query snippet, I am getting 404 bad request error
private static void UpdateConnection(string DatasetID)
{
string powerBIDatasetsApiUrl =String.Format("https://api.powerbi.com/v1.0/myorg/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=XXXXX;initial catalog=XXXXX;persist security info=True;encrypt=True;trustservercertificate=False\"}";
//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(); ----Error at this line
//Console.WriteLine(string.Format("Dataset {0}", response.StatusCode.ToString()));
Console.ReadLine();
}
}
Am I missing something? Please help
Thanks,
Latheesh
There'a actually an error in the Set All Connections API which leads to a 404 error. Try to remove the duplicated /myorg from the Url .../myorg/myorg/...
Thanks Eric,
I even tried removing myorg, but my error didn't get resolved.
@latheesh89 wrote:
Thanks Eric,
I even tried removing myorg, but my error didn't get resolved.
Where is the dataset in your case? If in some group, you'll specify the groupid in the POST request url. Can you double comfirm that the datasetid is correct?
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |