Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more
When I tried to create dataset using the following request. It is giving bad request error. What is wrong with this request and how can I make it work.
var client = GetPowerBIClient();
var datasets = client.Datasets;
var table = new Table
{
Name = "Sample",
Columns = new List<Column>
{
new Column
{
Name = "Name",
DataType = "string"
},
new Column
{
Name = "Id",
DataType = "Int64"
},
new Column
{
Name = "Type",
DataType = "string"
}
}
};
var request = new CreateDatasetRequest();
request.Name = "SampleDataSet";
request.Tables = new List<Table> { table };
var gateway = client.Gateways.GetGateways().Value.FirstOrDefault();
var credentials = new BasicCredentials("Username", "Password");
var credentialsEncryptor = new AsymmetricKeyEncryptor(gateway.PublicKey);
var credentialDetails = new CredentialDetails(credentials, PrivacyLevel.Private, EncryptedConnection.Encrypted, credentialsEncryptor);
var datasource = client.Gateways.GetDatasources(gateway.Id).Value.FirstOrDefault(d => d.DatasourceName == "Sample1");
request.Datasources = new List<Datasource>
{
new Datasource
{
Name = datasource.DatasourceName,
ConnectionDetails = new DatasourceConnectionDetails
{
Database = "databasename",
Server = "servername"
},
DatasourceType = "Sql",
DatasourceId = datasource.Id,
GatewayId = gateway.Id,
ConnectionString = "Server=servername;Database=databasename;User ID=userId;Password=Password;"
}
};
var response = datasets.PostDatasetInGroup(new Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx"), request);
Solved! Go to Solution.
HI @Anonymous,
According to the error message, it seems like they are something wrong with your HTTP request.
For this scenario, I'd like to suggest you take a look at the official document and push your dataset with the corresponding JSON format:
400 Bad Request - HTTP | MDN (mozilla.org)
Regards,
Xiaoxin Sheng
HI @Anonymous,
According to the error message, it seems like they are something wrong with your HTTP request.
For this scenario, I'd like to suggest you take a look at the official document and push your dataset with the corresponding JSON format:
400 Bad Request - HTTP | MDN (mozilla.org)
Regards,
Xiaoxin Sheng
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!
Check out the July 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 1 |