Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Hello,
I am trying to change the connection string using parameters, as described on this page: Change data source connection strings with PowerShell - Power BI | Microsoft Docs.
When I create a new Power BI report, everything works fine and I am able to modify the parameter (and thus the connection string).
But when adding a parameter to an existing Power BI report, I am not able to modify the value and get the following error message:
Failed to update data model parameters for [report path] The remote server returned an error: (500) Internal Server Error.
As described on the page, I first get the parameters with the Get-RsRestItemDataModelParameters function, then I modify the value and I use Set-RsRestItemDataModelParameters to apply to the report server.
Report server version: 9.7627.11028 (October 2020)
ReportingServicesTools PowerShell module : 0.0.5.9
Your help is very much appreciated,
Best regards,
Martin B.
Hello,
I am not using a list of values but just a default value. This parameter is used as connection string in the data source settings. I would like to programatically change the value via PowerShell , in order to modify the connection string during deployment to another environment. I have now more information about the error, this is what the report server logs shows: An item with the same key has already been added.
2021-01-07 16:17:57.8626|INFO|572|Received request POST /api/v2.0/PowerBIReports(Path='/TestReport')/DataModelParameters| RequestID = s_adfa12bb-a254-4bac-bdc9-41dd77cb36d7
2021-01-07 16:17:58.7062|ERROR|515|OData exception occurred: System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at Microsoft.ReportingServices.Portal.Repositories.CatalogItemRepository.SetDataModelDataSourcesTrusted(IPrincipal userPrincipal, Guid itemId, IEnumerable`1 dataSources, Boolean isOverwrite)
at Microsoft.ReportingServices.Portal.ODataWebApi.V2.Controllers.PowerBIReportsController.<PostDataModelParameters>d__33.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__1`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext().| RequestID = s_adfa12bb-a254-4bac-bdc9-41dd77cb36d7
How did you set up your parameter, you should have a list of names under Server Name and Database Name (the doc didn't mention), so you can edit parameter to switch between servers and databases. You can took a look at the desktop parameter that is same as Desktop for Report Server, this blog explains parameter in detail: Using Parameters in Power BI (mssqltips.com).
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.
I am working with the on-premises Power BI report server. I am now using the Invoke-RestMethod. I get an error but without any message:
Invoke-RestMethod : {"error":{"code":"0","message":""}}.
Please confirm if you are working with Power BI Report Server or with the regular Power BI Service.
For Service: Try doing the same call in the Power BI API sandbox. If that works, use the basic
Invoke-RestMethod (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Docs
or the slightly more luxurious
Invoke-PowerBIRestMethod (MicrosoftPowerBIMgmt.Profile) | Microsoft Docs
instead of your cmdlets.
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 1 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 2 |