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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
nlavalle
New Member

How to post a dataset with datasource using PowerBI REST API

Hello, following the API reference for the Push Dataset on https://docs.microsoft.com/en-us/rest/api/power-bi/pushdatasets/datasets_postdataset#datasource I'm trying to write a POST with a dataset that contains a datasource. Using the SalesMarketing and a random CSV as an example I've constructed the following json:

{
    "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"
          }
        ]
      }
    ],
    "datasources": [
        {
            "datasourceType": "Web",
            "connectionDetails": {
              "url": "https://community.watsonanalytics.com/wp-content/uploads/2015/08/WA_Sales_Products_2012-14.csv"
            }
          }
    ]
}
However this gives me a Bad Request 400 error when I perform the POST. Removing the datasources table allows it to successfully Push the Dataset. Could someone give me an example of a json push dataset that includes a data source?
 
Thanks
6 REPLIES 6
krish11
Frequent Visitor

Hey Did anyone found the solution yet? I am using same API and datasource is SQL. But don't know how to connect it to sql table instead of manual data entry?

Anonymous
Not applicable

Did you ever figure this out?

iafconsulting
New Member

I'm also wondering how to configure a datasource. Any luck with this one?

Hi Maggie,

 

Yes that is the example I have been following. It works without a datasource defined in the json request body, but that example doesn't include a datasource. I'm wondering what that example code would look like with a datasource included. It would occur during the Step 3, with the "string datasetJson =" line. I've still had no luck finding the proper syntax to include a datasource on the dataset creation.

Anonymous
Not applicable

Hi @nlavalle ,

 

Were you able to get a solution to your problem? Please share.

 

Thansk,

Sau

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Kudoed Authors