stansw / vsts-open-in-powerbi

Visual Studio Team Services extension which allows users to open queries in Power BI.
MIT License
19 stars 8 forks source link

JSON format error #7

Closed ems276 closed 7 years ago

ems276 commented 7 years ago

First off, great job!

Seems like the VSTS API is acting up or Power BI is interpreting things wrogn. The basic wiql result is not being interpreted correctly:

An error occurred in the ‘’ query. DataFormat.Error: We found extra characters at the end of JSON input. Details: Value= Position=4

A quick test of with a basic JSON query: = Json.Document(Web.Contents("https://xxx.visualstudio.com/DefaultCollection/_apis/wit/wiql/ab0f4c10-d255-40bd-81e4-d65937068c83?api-version=2.2"))

returns the same error

DataFormat.Error: We found extra characters at the end of JSON input. Details: Value= Position=4

ems276 commented 7 years ago

after some more digging, I had to enable 'alternate credentials' within the VSTS security (https://www.visualstudio.com/en-us/docs/setup-admin/team-services/use-personal-access-tokens-to-authenticate) for things to work.

stansw commented 7 years ago

I looked into this problem and it turned out that when you are not authorized VSTS might send login prompt (HTML) instead of the right Json document. I've added extra handling for that case to communicate that the problem is related to bad credentials.

https://github.com/stansw/vsts-open-in-powerbi/commit/5ef830fb89e1cd31a03ea3144112911c643eb62f#diff-7a218f88d6c4052eff232c14077cc97a