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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
rupali
Frequent Visitor

Power bi REST API for datasets to add rows

Hello ,

 

I have power bi Pro , I am following all documentation to GET /POST /PUT method for datasets and reports in groups. 

I can embedded reports succesfully in my App using power bi API . And even I am getting datasets ids.

 POWER BI REST API 

Q: How to add rows in dataset in Group? ( I have documentation link 

https://docs.microsoft.com/en-us/rest/api/power-bi/pushdatasets/datasets_postrowsingroup -  but before rows i need tables)

 

Now , I am trying to GET tables ,following below documentation:

https://docs.microsoft.com/en-us/rest/api/power-bi/pushdatasets/datasets_gettablesingroup

But , not getting tables.

Then I read in solution that we need to create dataset in app , then only we can create tables and add row in it . I tried this option too , but still not getting succes yet . 

This is my code : 

// for specific dataset with POST method(to crate dataset)
app.get("/dataset", [ensureAuthenticated, generatePBIAccessToken], function (req, res) {
    var data = req.query;
    data.user = req.user;
    var options = {
        method: 'POST',
        url: 'https://api.powerbi.com/v1.0/myorg/groups/' + app.locals.POWERBI_GROUP + '/datasets' ,
        headers: {
            'cache-control': 'no-cache',
            'authorization': 'Bearer ' + req.session.access_token,
            'content-type': 'application/x-www-form-urlencoded',
            'accepts': 'application/json',
            'charset': 'utf - 8',
            'request': 'System.Net.WebRequest.Create(powerBIDatasetsApiUrl) as System.Net.HttpWebRequest'
        },
        form: {
            "accessLevel": "View",
            "datasetId": req.query.datasetid,
            "allowSaveAs": true
        },
       body: {
           "name": "SalesMarketing",
           "defaultMode": "Push",
           "tables": [
               {
                   "name": "Product",
                   "columns": [
                       {
                           "name": "ProductID",
                           "dataType": "Int64"
                       },
                       {
                           "name": "Name",
                           "dataType": "string"
                       },
                       {
                           "name": "Category",
                           "dataType": "string"
                       },
                       {
                           "name": "IsCompete",
                           "dataType": "bool"
                       },
                       {
                           "name": "ManufacturedOn",
                           "dataType": "DateTime"
                       }
                   ]
               }
           ]
        } 
    };

    console.log("************************************ for datasetkeys");
    console.log(options);
    
    console.log("To create dataset  specific dataset with POST method");
    
    console.log("************************************");
    request(options, function (error, response, body) {
        if (error) throw new Error(error);
        data.embed = JSON.parse(body);
        res.render('pbi-dataset', data);
        
    });
});

 

and This is  output for above code : 

 

 tables.PNG

 

What I am missing ?  Please suggest thank in advance .

1 ACCEPTED SOLUTION
rupali
Frequent Visitor

Issue solved : 

var options = {
method: 'POST',
url: 'https://api.powerbi.com/v1.0/myorg/groups/' + app.locals.POWERBI_GROUP +'/datasets',
headers:
{
'Cache-Control': 'no-cache',
'Authorization': 'Bearer ' + req.session.access_token,
'Content-Type': 'application/json'
},
body:
{
name: 'Monthly Data',
defaultMode: 'Push',
tables:
[{
name: 'July-2018',
columns:
[{ name: 'ProductID', dataType: 'Int64' },
{ name: 'Name', dataType: 'string' },
{ name: 'Category', dataType: 'string' },
{ name: 'IsCompete', dataType: 'bool' },
{ name: 'ManufacturedOn', dataType: 'DateTime' }]
}]
},
//json: true
};

 

This is what I was missing , remove double quotes  "" which is bold in above code

View solution in original post

1 REPLY 1
rupali
Frequent Visitor

Issue solved : 

var options = {
method: 'POST',
url: 'https://api.powerbi.com/v1.0/myorg/groups/' + app.locals.POWERBI_GROUP +'/datasets',
headers:
{
'Cache-Control': 'no-cache',
'Authorization': 'Bearer ' + req.session.access_token,
'Content-Type': 'application/json'
},
body:
{
name: 'Monthly Data',
defaultMode: 'Push',
tables:
[{
name: 'July-2018',
columns:
[{ name: 'ProductID', dataType: 'Int64' },
{ name: 'Name', dataType: 'string' },
{ name: 'Category', dataType: 'string' },
{ name: 'IsCompete', dataType: 'bool' },
{ name: 'ManufacturedOn', dataType: 'DateTime' }]
}]
},
//json: true
};

 

This is what I was missing , remove double quotes  "" which is bold in above code

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.