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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
ITInge
Frequent Visitor

Set PowerBI datasource parameters programatically using PBI API

I would like to update my datasource credentials to AzureTable Storage.

To know how is the format of the credentials I maked a Get datasources infos on an existing already linked dataset ( via power bi desktop )

 

{
"@odata.context": "http://wabi-west-europe-b-primary-redirect.analysis.windows.net/v1.0/myorg/groups/xxxxxxxxxxxxxxx/$metadata#datasources",
"value": [
{
"datasourceType": "AzureTables",
"connectionDetails": {
"account": "storageName",
"domain": "table.core.windows.net"
},
"datasourceId": "1a2bd852-8447-440b-b1c6-xxxxxxxxxx",
"gatewayId": "4aa719f9-565e-450b-b6a6xxxxxx"
}
]
}

 

So I tried to use the same structure to push a new dataset linked to this datasource using push API

Here's my request body

{
"name": "test",
"defaultMode": "Push",
"tables": [],
"datasources": 
{
"datasourceType": "AzureTables",
"connectionDetails": {
"account": "prodcallrecord",
"domain": "table.core.windows.net"
},
"datasourceId": "1a2bd852-8447-440b-b1c6-xxxxxxx",
"gatewayId": "4aa719f9-565e-450b-b6a6-xxxxxxxxx"
}

}

Unfortunately I get this error

{
"error": {
"code": "InvalidRequest",
"message": "TOM deserialization failed for database sobe_wowvirtualserver|796c45fc-7f73-4711-a380-81465baedba7, Exception: <pi>Unrecognized JSON property: datasources. Check path 'datasources', line 1, position 60.</pi>"
}
}

 

I don't know where I've messed , is it because AzureTable is not supported from the PowerBi API ?

Is there another way to do this ?

 

1 ACCEPTED SOLUTION

Hi @ITInge,

According to your error message, I think it means you are using the wrong update detailed in the rest API.

For this scenario, I'd like to suggest you use 'Get Datasources In Group' API to get the detailed configurations and setting of your data source, then you can use them in update data source API:

Datasets - Get Datasources In Group 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

5 REPLIES 5
pbillava
Frequent Visitor

Hey Hi,

 

di you get this working? If yes please share how you got this done.

lbendlin
Super User
Super User

Use the sandbox (the "Try it!" button on the link I posted) to figure out the right parameters for your API call.

lbendlin
Super User
Super User

The Push API is not doing what you think it does. It is used for pushing data into streaming datasets.

 

You need to use different API calls.

Something like this: Datasets - Update Datasources In Group (Power BI Power BI REST APIs) | Microsoft Docs

Thanks for the reply , effectively I was trying to make update with this API today , 

My actual issue is to use the right body params to update the datasource.

Here's what the API preconize.

 

"updateDetails": [ { "datasourceSelector": { "datasourceType": "Sql", "connectionDetails": { "server": "My-Sql-Server", "database": "My-Sql-Database" } }, "connectionDetails": { "server": "New-Sql-Server", "database": "New-Sql-Database" } },

 

 Here's what I'm sending 

I'm gettin 400 error 

 

 

{
   "updateDetails":[
      {
         "datasourceSelector":{
            "datasourceType":"AzureTables",
            "connectionDetails":{
               "account":"prodcallxxx",
               "domain":"table.core.windows.net"
            },
            "datasourceId":"2b23933c-34a7-4247-94ff-xxxxxx",
            "gatewayId":"d1e2a03c-0f55-42fe-b0dd-xxxxxxx"
         },
         "connectionDetails":{
            "account":"prodcallrecord",
            "domain":"table.core.windows.net"
         }
      }
   ]
}


Error

 

{
  "error": {
    "code": "InvalidRequest",
    "message": "Parameter UpdateDetails is missing or invalid"
  }
}

 

Hi @ITInge,

According to your error message, I think it means you are using the wrong update detailed in the rest API.

For this scenario, I'd like to suggest you use 'Get Datasources In Group' API to get the detailed configurations and setting of your data source, then you can use them in update data source API:

Datasets - Get Datasources In Group 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.