Showing results for 
Search instead for 
Did you mean: 
Helper V
Helper V

Create data source from REST API

Hi everyone, 

I am trying to add a file type data source using REST API, however it is failing. I have tried with Service Principal as well as a usual user with PBI Pro license and admin rights on the gateway but no luck. I am wondering if I can get some help and can be guided in the right direction.

My calls are as below

JSON For data source connection

"datasourceName": "testDataSource",
"credentialDetails": {
"encryptedConnection": "Encrypted",
"credentialType": "Windows",
"credentials": {
"UserName": "<user_name_or_service_principal_ID>",
"Password": "System.Security.SecureString"
"privacyLevel": "Organizational",
"encryptionAlgorithm": "None"
"dataSourceType": "=File",
"connectionDetails": "{\"FilePath\":\"C:\\Working\\some.csv\"}"


REST API End Point<gateway_id>/datasources



Invoke-WebRequest : The remote server returned an error: (400) Bad Request.



Community Support
Community Support

Hi @krajani ,


Please refer the following posts, they might be helpful.


If it doesn’t meet your requirement, we suggest you to open a ticket here for help:


Support Ticket .gif


Best regards,


Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Kudoed Authors