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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ManishSingh007
Regular Visitor

Gateways: Power BI REST API - Unable To Create Folder Data Source Type!!! Help

Invoke-PowerBIRestMethod : One or more errors occurred.
At C:\Users\---\Desktop\*******\******\PowerShell\FinalCode\File1.ps1:184 char:1
+ Invoke-PowerBIRestMethod -Url $CreateDatasourceUrl -Method Post -Body ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], AggregateException
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod

Invoke-PowerBIRestMethod : Encountered errors when invoking the command: {
"code": "DMTS_UnsupportedConnectionStringError",
"pbi.error": {
"code": "DMTS_UnsupportedConnectionStringError",
"parameters": {},
"details": [],
"exceptionCulprit": 1
}
}
At C:\Users\chaudman\Desktop\TampereProject\sarika\PowerShell\FinalCode\File1.ps1:184 char:1
+ Invoke-PowerBIRestMethod -Url $CreateDatasourceUrl -Method Post -Body ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], Exception
+ FullyQualifiedErrorId : Encountered errors when invoking the command: {
"code": "DMTS_UnsupportedConnectionStringError",
"pbi.error": {
"code": "DMTS_UnsupportedConnectionStringError",
"parameters": {},
"details": [],
"exceptionCulprit": 1
}
},Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod

4 REPLIES 4
ManishSingh007
Regular Visitor

I am not sure, just wanted to create 'Folder' as a data source connection under on-primese Gateway using power shell script, could you please suggest, 

 

$datasourceType = "Folder"
$GatewayId = ""
$CreateDatasourceUrl = "https://api.powerbi.com/v1.0/myorg/gateways/$GatewayId/datasources"

$encryptedCredentials = EncryptWindowsCredentials -Username $username -PasswordAsString $password -GatewayExponent $gatewayExponent -GatewayModulus $gatewayModulus
$credentialsObject = $encryptedCredentials | ConvertFrom-Json
$credentialDetails = $credentialsObject.credentialDetails

$Body = @{
"datasourceType"=$datasourceType
"connectionDetails"='{"full path":"\\WPF3HPGEK\Users\chaudman\Desktop\TP\arika\PowerShell\"}' #'{"server":"WPF3HPGEK","database":"DemoDb"}'#'{"server":"<serverName>","database":"<DBName>"}'
"datasourceName"=$datasourceName
"credentialDetails" = @{
"credentialType" = $credentialDetails.credentialType
"credentials" = $credentialDetails.credentials
"encryptedConnection" = $credentialDetails.encryptedConnection
"encryptionAlgorithm" = $credentialDetails.encryptionAlgorithm
"privacyLevel" = $credentialDetails.privacyLevel
}
}
$bodyJson = $body | ConvertTo-Json

Invoke-PowerBIRestMethod -Url $CreateDatasourceUrl -Method Post -Body $bodyJson

Try it out in the sandbox.  Make sure the gateway can see your share.

Gateways - Create Datasource - REST API (Power BI Power BI REST APIs) | Microsoft Learn

lbendlin
Super User
Super User

Does it work in the API sandbox?

It is not working, Could you please suggest

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors