Forum Discussion

bartp's avatar
bartp
New Member
4 years ago

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

  • Anonymous's avatar
    Anonymous
    Not applicable

    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.

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