Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
I have the following code and when I start creating a new database on the line: writer s request. GetRequestStream())
I skip the following error:
IOException: Cannot write data from to transport connection: An existing connection has been forced to be interrupted by the remote host.
SocketException: An existing connection has been forced to be interrupted by the remote host
Do you know how it can be solvent?
According to the powerbi forums the code is correct and 4 months ago it worked
#region Create a dataset in Power BI
private static void CreateDataset()
{
//TODO: Add using System.Net and using System.IO
string powerBIDatasetsApiUrl = "https://api.powerbi.com/v1.0/myorg/datasets";
//POST web request to create a dataset.
//To create a Dataset in a group, use the Groups uri: https://api.PowerBI.com/v1.0/myorg/groups/{group_id}/datasets
HttpWebRequest request = System.Net.WebRequest.Create(powerBIDatasetsApiUrl) as System.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));
//Create dataset JSON for POST request
string datasetJson = "{\"name\": \"SalesMarketing\", \"tables\": " +
"[{\"name\": \"Product\", \"columns\": " +
"[{ \"name\": \"ProductID\", \"dataType\": \"Int64\"}, " +
"{ \"name\": \"Name\", \"dataType\": \"string\"}, " +
"{ \"name\": \"Category\", \"dataType\": \"string\"}," +
"{ \"name\": \"IsCompete\", \"dataType\": \"bool\"}," +
"{ \"name\": \"ManufacturedOn\", \"dataType\": \"DateTime\"}" +
"]}]}";
//POST web request
byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(datasetJson);
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();
}
}
#endregion
}
}
Hi, @alexmorgan
I am not very familiar with the codes. You may refer to the document to see if Power BI Rest API helps.
Best Regards
Allan
If this post helps,then consider Accepting it as the solution to help other members find it faster.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 103 | |
| 80 | |
| 63 | |
| 50 | |
| 45 |