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

 

 

V-pazhen-msft
Community Support
Community Support

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