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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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 = "";
            //POST web request to create a dataset.
            //To create a Dataset in a group, use the Groups uri:{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 } }

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



If this post helps,then consider Accepting it as the solution to help other members find it faster.

Helpful resources

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.


Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.