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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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