Forum Discussion
How to connect Jira REST API as data source? Power BI Service friendly and with pagination??
- Anonymous2 years ago
Hi Alina12 ,
Hope all is going well.
Please follow these steps:
1. The error you are encountering in the function is due to attempting to concatenate a binary () with a string. Since is used with , it is treated as a binary.
You should modify your approach to use and options within for pagination as well.GetJiraIDCountBaseUrlBaseUrlWeb.ContentsRelativePathQueryWeb.Contents
2. Modify the GetPage function:
GetPage = (Index) => let Skip = Text.From(Index * JiraIDPerPage), Top = Text.From(JiraIDPerPage), PageData = Web.Contents( https://XXX.XXX.net/jira/rest/api, [ RelativePath="2/search", Query= [ jql="filter=525545", startAt=Skip, maxResults=Top, fields="issuetype,key,summary,customfield_10401,labels,customfield_10000,status,resolution,customfield_11200" ], Headers=[Authorization="Bearer XXX"] ] ), Json = Json.Document(PageData), Value = Json[#"issues"] in Value,If you have other questions, please contact me at any time.
Best Regards,
Yang
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
UPDATE
I have managed to get the code to work with Web.Contents, Relative Path and Query. The problem now is that a) I only get the first 1000 hits instead of approx. 5,500 hits (although JiraIDCount shows the correct number of total hits) and b) it still shows me a dynamic data source and the data refresh is not possible.
So it seems that my problem might be with the pagination, because the whole www says that the dynamic data refresh should work with Web.Contents, Relative Path and Query. Can anyone help me?
let
BaseUrl =
Web.Contents(
"https://XXX.XXX.net/jira/rest/api",
[
RelativePath="2/search",
Query=
[
jql="filter=525545",
maxResults="1000",
fields="issuetype,key,summary,customfield_10401,labels,customfield_10000,status,resolution,customfield_11200"
],
Headers=
[
Authorization="Bearer XXX"
]
]
) ,
JiraIDPerPage = 1000,
GetJson = (Url) =>
let
RawData = BaseUrl,
Json = Json.Document(RawData)
in Json,
GetJiraIDCount = () =>
let Url = BaseUrl,
Json = GetJson(Url),
Count = Json[#"total"]
in Count,
GetPage = (Index) =>
let Skip = "&startAt=" & Text.From(Index * JiraIDPerPage),
Top = "&maxResults=" & Text.From(JiraIDPerPage),
Url = Text.From(BaseUrl) & Skip & Top,
Json = GetJson(Url),
Value = Json[#"issues"]
in Value,
JiraIDCount = List.Max({ JiraIDPerPage, GetJiraIDCount() }),
PageCount = Number.RoundUp(JiraIDCount / JiraIDPerPage),
PageIndices = { 0 .. PageCount - 1 },
Pages = List.Transform(PageIndices, each GetPage(_)),
JiraID = List.Union(Pages),
Table = Table.FromList(JiraID, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
...