Hi @Mo.jo.jo ,
Here’s some error handling for you, LOL.
Let’s see what happens…
(Page as number) =>
let
Source = try Json.Document(Web.Contents("https://api.bimtrackapp.co" & "/v3/hubs/{hubId}/projects/{ProjectId}/issues?sort=+Number&startRecord="&Number.ToText(Page)&"&returnCount=100", [Headers=[Authorization="Bearer {access token}"]]))
otherwise null,
ToTable = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
ExpandTable = try Table.ExpandRecordColumn(ToTable, "Column1", {"Id", "ProjectId", "Title", "Number", "Description", "Group", "Author", "AssignedTo", "LastModificationAuthor", "LastModificationDate", "DueDate", "CreationDate", "ClosingDate", "DefaultViewpointId", "Disciplines", "ProjectPhase", "ProjectZone", "Priority", "Status", "Type", "Confidentiality", "NotifyList", "CustomAttributes", "CreationSource", "Viewpoints", "IsRestricted"}, {"Id", "ProjectId", "Title", "Number", "Description", "Group", "Author", "AssignedTo", "LastModificationAuthor", "LastModificationDate", "DueDate", "CreationDate", "ClosingDate", "DefaultViewpointId", "Disciplines", "ProjectPhase", "ProjectZone", "Priority", "Status", "Type", "Confidentiality", "NotifyList", "CustomAttributes", "CreationSource", "Viewpoints", "IsRestricted"})
otherwise #table( {"Id", "ProjectId", "Title", "Number", "Description", "Group", "Author", "AssignedTo", "LastModificationAuthor", "LastModificationDate", "DueDate", "CreationDate", "ClosingDate", "DefaultViewpointId", "Disciplines", "ProjectPhase", "ProjectZone", "Priority", "Status", "Type", "Confidentiality", "NotifyList", "CustomAttributes", "CreationSource", "Viewpoints", "IsRestricted"}, {} ),
ExpandAuthor = try Table.ExpandRecordColumn(ExpandTable, "Author", {"Id", "UserName", "Email", "FirstName", "LastName", "AvatarUrl"}, {"Author.Id", "Author.UserName", "Author.Email", "Author.FirstName", "Author.LastName", "Author.AvatarUrl"})
otherwise #table( {"Author.Id", "Author.UserName", "Author.Email", "Author.FirstName", "Author.LastName", "Author.AvatarUrl"}, {} ),
ExpandAssignedTo = try Table.ExpandRecordColumn(ExpandAuthor, "AssignedTo", {"Id", "UserName", "Email", "FirstName", "LastName", "AvatarUrl"}, {"AssignedTo.Id", "AssignedTo.UserName", "AssignedTo.Email", "AssignedTo.FirstName", "AssignedTo.LastName", "AssignedTo.AvatarUrl"})
otherwise #table( {"AssignedTo.Id", "AssignedTo.UserName", "AssignedTo.Email", "AssignedTo.FirstName", "AssignedTo.LastName", "AssignedTo.AvatarUrl"}, {} ),
ExpandLastModAuthor = try Table.ExpandRecordColumn(ExpandAssignedTo, "LastModificationAuthor", {"Id", "UserName", "Email", "FirstName", "LastName", "AvatarUrl"}, {"LastModificationAuthor.Id", "LastModificationAuthor.UserName", "LastModificationAuthor.Email", "LastModificationAuthor.FirstName", "LastModificationAuthor.LastName", "LastModificationAuthor.AvatarUrl"})
otherwise #table( {"LastModificationAuthor.Id", "LastModificationAuthor.UserName", "LastModificationAuthor.Email", "LastModificationAuthor.FirstName", "LastModificationAuthor.LastName", "LastModificationAuthor.AvatarUrl"}, {} ),
ExpandProjectPhase = try Table.ExpandRecordColumn(ExpandLastModAuthor, "ProjectPhase", {"Color", "Name", "Id"}, {"ProjectPhase.Color", "ProjectPhase.Name", "ProjectPhase.Id"})
otherwise #table( {"ProjectPhase.Color", "ProjectPhase.Name", "ProjectPhase.Id"}, {} ),
ExpandProjectZone = try Table.ExpandRecordColumn(ExpandProjectPhase, "ProjectZone", {"Color", "Name", "Id"}, {"ProjectZone.Color", "ProjectZone.Name", "ProjectZone.Id"})
otherwise #table( {"ProjectZone.Color", "ProjectZone.Name", "ProjectZone.Id"}, {} ),
ExpandPriority = try Table.ExpandRecordColumn(ExpandProjectZone, "Priority", {"Order", "Color", "Name", "Id"}, {"Priority.Order", "Priority.Color", "Priority.Name", "Priority.Id"})
otherwise #table( {"Priority.Order", "Priority.Color", "Priority.Name", "Priority.Id"}, {} ),
ExpandStatus = try Table.ExpandRecordColumn(ExpandPriority, "Status", {"TeamsAllowedForStatus", "Color", "Name", "Id"}, {"Status.TeamsAllowedForStatus", "Status.Color", "Status.Name", "Status.Id"})
otherwise #table( {"Status.TeamsAllowedForStatus", "Status.Color", "Status.Name", "Status.Id"}, {} ),
ExpandType = try Table.ExpandRecordColumn(ExpandStatus, "Type", {"Color", "Name", "Id"}, {"Type.Color", "Type.Name", "Type.Id"})
otherwise #table( {"Type.Color", "Type.Name", "Type.Id"}, {} ),
ExpandConfidentiality = try Table.ExpandRecordColumn(ExpandType, "Confidentiality", {"Teams"}, {"Confidentiality.Teams"})
otherwise #table( {"Confidentiality.Teams"}, {} ),
ExpandNotifyList = try Table.ExpandRecordColumn(ExpandConfidentiality, "NotifyList", {"TeamsToNotify", "UsersToNotify"}, {"NotifyList.TeamsToNotify", "NotifyList.UsersToNotify"})
otherwise #table( {"NotifyList.TeamsToNotify", "NotifyList.UsersToNotify"}, {} ),
SortRows = Table.Sort(ExpandNotifyList,{{"Number", Order.Ascending}})
in
if Source = null then Source else SortRows
I hope this is helpful.