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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Kudoed Authors