Forum Discussion
Dataset credential is missing while publishing using Rest Api for report based on SharePoint Excel
HI nilanjanpalMol,
>>My SharePoint Credential and Power BI Service credential are different.
For power bi service report dataset settings, it required you use the same credentials used in the power bi desktop.
If you are confused about using rest API with OAuth authorization, you can refer to the following link:
Solved: Pull data from a REST API Authentication - Microsoft Power BI Community
If you are not sure about the data source connections in the rest API, you can try to use rest API 'get datasource' to get the result from a similar type of data source as a template to modify and use in your request.
Datasets - Get Datasources - REST API (Power BI Power BI REST APIs) | Microsoft Docs
Datasets - Get Datasources In Group - REST API (Power BI Power BI REST APIs) | Microsoft Docs
Notice: web type data source normally used 'anonymous' authorizations, the data source credentials and verifications operations will be attached to the query table steps.
Regards,
Xiaoxin Sheng
Dear Xiaoxin Sheng,
Thank you very much for your help.
I have successfully fetched the datasource details.
Now I want to set credential using Power BI Rest API. I am using below code as I mentioned in my previous comment.
var delta = new UpdateDatasourceRequest
{
CredentialDetails = new CredentialDetails
{
CredentialType = "OAuth2",
Credentials= "{\"credentialData\":[{\"name\":\"accessToken\", \"value\":\"" + t.AccessToken + "\"}]}",
EncryptedConnection= "Encrypted",
EncryptionAlgorithm= "None",
PrivacyLevel= "None",
UseEndUserOAuth2Credentials = true
}
};
await client.Gateways.UpdateDatasourceAsync(datasource.Value[0].GatewayId, datasource.Value[0].Id, delta);
I am getting below error:
"{\"error\":{\"code\":\"InvalidRequest\",\"message\":\"Property useEndUserOAuth2Credentials is only supported with credentials of type OAuth2 and datasource type of Web\"}}"
I am not very sure, if “Anonymous” authentication will be used or not. As you suggested, I tried to use anonymous authentication from Power BI desktop. It was not worked.
Also it will be helpful, if you suggest any link where I will be able to get any example of OAuth authentication for setting dataset credential using Power BI Rest API.
I have already implemented "Basic" authentication (using Power BI Api) for setting credential for database based Power BI report. For OAuth authentication I am getting problem.
With regards
Nilanjan
- Anonymous4 years agoNot applicable
HI nilanjanpalMol,
Have you tried to update on the power bi service side to confirm these credentials are valid for your datasets?
If your request worked to use 'base' authorization and the OAuth mode work on power bi service, it may mean the OAuth data credentials are currently not able directly configurated by API.
Regards,Xiaoxin Sheng