Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
alexmorgan
Regular Visitor

Error al crear datasets

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 } }

1 REPLY 1
v-alq-msft
Community Support
Community Support

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.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors