I created a REST API that is responsible for updating the data source of the specific report and then refreshing it.
API to update the datasource: https://api.powerbi.com/v1.0/myorg/datasets/{datasetId}/Default.UpdateDatasources
API to refresh the dataset:
https://api.powerbi.com/v1.0/myorg/datasets/{datasetId}/refreshes
When I try to refresh the dataset, I get some credentials related error:
The refresh failed for this model. Expand the technical details for more info.Hide details
Data source error: It looks like scheduled refresh failed because at least one data source is missing credentials. To start the refresh again, go to this dataset's settings page and enter credentials for all data sources.
Cluster URI: WABI-INDIA-CENTRAL-A-PRIMARY-redirect.analysis.windows.net
Activity ID: 00000000-0000-0000-0000-000000000000
Request ID: ff70b198-de5a-4572-b36f-78858b062ef3
Time: 2024-12-09 05:52:16Z
Under the Data source credentials section in settings page I get this error:
Failed to test the connection to your data source. Please retry your credentials.Learn more
After this, I have to enter the credentials manually (after every request).
Is there any way to persist this credentials ?
2
Answers
When your credentials are incorrect while testing the data source, you will get above error. Edit the credentials correctly.
Once check your credentials type of data source, if it is Anonymous, change it to Basic, provide the credential and publish the report, wait for some time after the publish, you may get relief from above error. Otherwise, check the permissions of Datasource by going to global permissions as shown below:
According to the MS document
This error can occur when the gateway attempts a test connection, even if the credentials supplied are acceptable and the refresh operation is successful. It happens because when the gateway performs a connection test, it doesn’t include any optional parameters during the connection attempt, and some data connectors, (Snowflake, for example) require optional connection parameters in order to connect.
When your refresh is completing properly and you don’t experience runtime errors, you can ignore these test connection errors for data sources that require optional parameters. For more information you can refer to the below documents:
https://community.fabric.microsoft.com/t5/Service/Power-BI-not-saving-basic-authentication-credentials-during/m-p/358968
Why does PowerBI ask for credentials when refreshi… – Microsoft Fabric Community
In my case after change parameters for each one of the sources I could fix this issue. For some reason it started considering fix IP and disabled parameters, I edited it via PBI Desktop, remove the fix IP and add parameters (server and database).
from
= PostgreSQL.Database("111.111.111.111:PORT", db_prod)
to
= PostgreSQL.Database(Server_IP, Database)