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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Martin51
Frequent Visitor

Failed to update data model parameters - using new October update way to change connection string

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.

4 REPLIES 4
Martin51
Frequent Visitor

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

 

 

Anonymous
Not applicable

@Martin51 


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).

V-pazhen-msft_0-1609469165447.png


Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

 

Martin51
Frequent Visitor

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":""}}.
lbendlin
Super User
Super User

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.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.