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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Anonymous
Not applicable

Update SSAS Live dataset connection via Power BI API

Hi All,

 

After publishing a report(SSAS Live) to the service, I am trying to access the report from my app and update the connection string using the code below but I always get an error "Operation returned an invalid code, "BadRequest"". The SetAllDatasetConnectionsInGroup worked fine for all DirectQuery reports we had. We are trying to switch over to SSAS for better performance.

 

P.S. I am trying to use the CustomData property of the SSAS connectionString to pass in the custom value for RLS

 

Snippet

try
{
    if (!string.IsNullOrEmpty(connectionString))
    {
        var connectionDetails = new ConnectionDetails()
        {
            ConnectionString = connectionString
        };
        var powerBiClient = await _client.GetPowerBiClient();
        var response = powerBiClient.Datasets.SetAllDatasetConnectionsInGroup(groupId, datasetId, connectionDetails);
        LogHelper.LogInfo(string.Format("Dataset {0} in workspace {1} update with connection string {2}", datasetId, groupId, connectionString));
 
        return TaskStatus.Completed;
    }
    else
    {
        LogHelper.LogError("Connection String cannot be null or empty");
        return TaskStatus.Failed;
    }
}
catch (Exception ex)
{
    LogHelper.LogError(ex);
    return TaskStatus.Failed;
}

 

1 ACCEPTED SOLUTION
Eric_Zhang
Microsoft Employee
Microsoft Employee


@Anonymous wrote:

Hi All,

 

After publishing a report(SSAS Live) to the service, I am trying to access the report from my app and update the connection string using the code below but I always get an error "Operation returned an invalid code, "BadRequest"". The SetAllDatasetConnectionsInGroup worked fine for all DirectQuery reports we had. We are trying to switch over to SSAS for better performance.

 

P.S. I am trying to use the CustomData property of the SSAS connectionString to pass in the custom value for RLS

 

Snippet

try
{
    if (!string.IsNullOrEmpty(connectionString))
    {
        var connectionDetails = new ConnectionDetails()
        {
            ConnectionString = connectionString
        };
        var powerBiClient = await _client.GetPowerBiClient();
        var response = powerBiClient.Datasets.SetAllDatasetConnectionsInGroup(groupId, datasetId, connectionDetails);
        LogHelper.LogInfo(string.Format("Dataset {0} in workspace {1} update with connection string {2}", datasetId, groupId, connectionString));
 
        return TaskStatus.Completed;
    }
    else
    {
        LogHelper.LogError("Connection String cannot be null or empty");
        return TaskStatus.Failed;
    }
}
catch (Exception ex)
{
    LogHelper.LogError(ex);
    return TaskStatus.Failed;
}

 


@Anonymous

AFAIK, it is a limitation. The underlying REST API Set All Connections only supports DirectQuery datasource, the SSAS live connection is not treated as DQ mode anyhow.

View solution in original post

4 REPLIES 4
Eric_Zhang
Microsoft Employee
Microsoft Employee


@Anonymous wrote:

Hi All,

 

After publishing a report(SSAS Live) to the service, I am trying to access the report from my app and update the connection string using the code below but I always get an error "Operation returned an invalid code, "BadRequest"". The SetAllDatasetConnectionsInGroup worked fine for all DirectQuery reports we had. We are trying to switch over to SSAS for better performance.

 

P.S. I am trying to use the CustomData property of the SSAS connectionString to pass in the custom value for RLS

 

Snippet

try
{
    if (!string.IsNullOrEmpty(connectionString))
    {
        var connectionDetails = new ConnectionDetails()
        {
            ConnectionString = connectionString
        };
        var powerBiClient = await _client.GetPowerBiClient();
        var response = powerBiClient.Datasets.SetAllDatasetConnectionsInGroup(groupId, datasetId, connectionDetails);
        LogHelper.LogInfo(string.Format("Dataset {0} in workspace {1} update with connection string {2}", datasetId, groupId, connectionString));
 
        return TaskStatus.Completed;
    }
    else
    {
        LogHelper.LogError("Connection String cannot be null or empty");
        return TaskStatus.Failed;
    }
}
catch (Exception ex)
{
    LogHelper.LogError(ex);
    return TaskStatus.Failed;
}

 


@Anonymous

AFAIK, it is a limitation. The underlying REST API Set All Connections only supports DirectQuery datasource, the SSAS live connection is not treated as DQ mode anyhow.

Anonymous
Not applicable

I really hope this is not the case...

Anonymous
Not applicable

You cannot update dataset connection string if you have  a  SSAS live connection report. We are struggling maintaining model per client.. its crazy!

Anonymous
Not applicable

I have approximately 5000 individual reports, each with a specific connection string.  We need to change them to imported mode.  I can change the connection string while they are using direct query.  But they are sluggish as hell unless we change them to imported mode.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.