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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
bartp
New Member

PowerBI Client issue ("element as type incompatible with the array") after SharePoint 13->16 upgrade

I'm getting error when trying to get PowerBI report:

 

using Microsoft.PowerBI.Api.V2;
using Microsoft.PowerBI.Api.V2.Models;

// ...

UserPasswordCredential userCredential = new UserPasswordCredential(Username, Password);
AuthenticationContext ctx = new AuthenticationContext(AuthorityUrl);
Task<AuthenticationResult> task = ctx.AcquireTokenAsync(ResourceUrl, ApplicationId, userCredential);
AuthenticationResult authResult = task.Result;


if (authResult != null)
{
	TokenCredentials credentials = new TokenCredentials(authResult.AccessToken, "Bearer");

	using (PowerBIClient powerBIClient = new PowerBIClient(new Uri(ApiUrl), credentials))
	{
		// ...
	}
}

 

Error:

System.ArrayTypeMismatchException: Attempted to access an element as a type incompatible with the array.
at System.Collections.Generic.List`1.Add(T item)
at Microsoft.PowerBI.Api.V2.PowerBIClient.Initialize()
at Microsoft.PowerBI.Api.V2.PowerBIClient..ctor(Uri baseUri, ServiceClientCredentials credentials, DelegatingHandler[] handlers)

 

It works on SharePoint 2013. After upgrade to SharePoint 2016 started getting this issue. Parameters to connect and get PowerBI report are the same in both cases.

 

I found one solution with trying different versions of Newtonsoft.Json library, but it didn't help

2 REPLIES 2
bartp
New Member

I have found that:

On machine where it works with SharePoint 2013 - it works only if opened from different machine. When opened on the same server where it is deployed, it is the same issue.

v-rzhou-msft
Community Support
Community Support

Hi @bartp ,

 

What kind of embedding method are you choosing to use in Sharepoint 2016, publish to web?

As far as I know, the classic SharePoint Server is not supported with embedding to SharePoint Online.

For reference: Known issues and limitations

According to your screenshot, I think there should be something wrong in authentication. I think you can try to delete the cache , then get the embed code and bear token and try again.

Here is a solved post with similar problem like yours, I hope it could help you solve your problem.

For reference: Embed Power BI report on SharePoint on-prem page, SP List as data source &amp; repeatable deployment...

 

Best Regards,
Rico Zhou

 

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

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.