I am a bit beginner of powerbi, I want to call api from power bi to get some data.
I tried to write this code but always return this error once I clicked invoke button
Here is the code that I used:
let
GetWorkItemIds = () =>
let
Source = Json.Document(Web.Contents("https://dev.azure.com/XXX/XXX/_apis/wit/workitems/13?api-version=7.0")),
workItems = Source[workItems],
#"Converted to Table" = Table.FromList(workItems, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expand Ids" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id"}, {"Work Item Id"})
in
#"Expand Ids"
in
GetWorkItemIds
Anyone can give idea please. Thanks a lot
CodePudding user response:
Your JSON isn't correct. Try this and see what comes back in the preview window.
let
Source = Web.Contents("https://dev.azure.com/XXX/XXX/_apis/wit/workitems/13?api-version=7.0")
in
Source
CodePudding user response:
Based on the documentation on the API endpoint response, it looks to me like you are treating the response erroneously. The endpoint does not return a list of work items, but a JSON representing one singular work item based on its ID - in your case ID = 13
.
As you can see in the linked documentation, the response does not contain anything called workItems
, which I suspect is causing your error.
However, I think your error stems from lack of authentication.