Just for community benefits i am providing the code which i am using in Power BI Desktop.
I am seeing Import Mode in Model of the query. Could you please help how can i refresh the data directly in service without using On-Premise Data gateway?
----------------Advance Query Code --------------
let
GetJiraData = (projectCode as text, authToken as text, componentFilter as text) =>
let
// Helper function to fetch data from Jira API
FetchData = (startAt as number, jiracode, auth, component) =>
let
componenturl = if component = null or component = "" then "" else " and component='" & component & "'",
Headers=[Authorization="Basic " & Binary.ToText(Text.ToBinary("mail id:API Token"), BinaryEncoding.Base64)],
Source = Json.Document(Web.Contents(URL, [Headers = Headers]))
in
Source,
// Pagination helper function
FetchPage = (startAt, jiracode, auth, component) as record =>
let
Data = FetchData(startAt, jiracode, auth, component),
Items = Data[issues],
Total = Data[total]
in
[Items = Items, Total = Total],
// Initial data fetch and pagination setup
InitialFetch = FetchPage(0, projectCode, authToken, componentFilter),
FirstItems = InitialFetch[Items],
Total = InitialFetch[Total],
PageSize = 100,
NumPages = Number.RoundUp(Total / PageSize),
PageOffsets = List.Transform({1..NumPages - 1}, each _ * PageSize),
// Fetch remaining pages and combine all data
OtherPages = List.Transform(PageOffsets, each FetchPage(_, projectCode, authToken, componentFilter)[Items]),
AllItems = List.Combine({FirstItems} & OtherPages),
// Convert to table and begin transformations
ConvertedToTable = Table.FromList(AllItems, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
// Expand main issue structure
ExpandedColumn1 = Table.ExpandRecordColumn(ConvertedToTable, "Column1",
{"expand", "id", "self", "key", "fields"},
{"issues.expand", "issues.id", "issues.self", "issues.key", "issues.fields"}),
// Expand main fields
ExpandedIssueFields = Table.ExpandRecordColumn(ExpandedColumn1, "issues.fields",
{"resolution", "aggregatetimeoriginalestimate", "assignee", "votes", "issuetype", "timeestimate", "status", "aggregatetimeestimate", "creator", "timespent", "aggregatetimespent", "workratio", "labels", "components", "reporter", "progress", "project", "resolutiondate", "watches", "updated", "timeoriginalestimate", "description", "summary", "statuscategorychangedate", "fixVersions", "priority", "versions", "created", "security", "parent", "customfield_20757"},
{"issues.fields.resolution", "issues.fields.aggregatetimeoriginalestimate", "issues.fields.assignee", "issues.fields.votes", "issues.fields.issuetype", "issues.fields.timeestimate", "issues.fields.status", "issues.fields.aggregatetimeestimate", "issues.fields.creator", "issues.fields.timespent", "issues.fields.aggregatetimespent", "issues.fields.workratio", "issues.fields.labels", "issues.fields.components", "issues.fields.reporter", "issues.fields.progress", "issues.fields.project", "issues.fields.resolutiondate", "issues.fields.watches", "issues.fields.updated", "issues.fields.timeoriginalestimate", "issues.fields.description", "issues.fields.summary", "issues.fields.statuscategorychangedate", "issues.fields.fixVersions", "issues.fields.priority", "issues.fields.versions", "issues.fields.created", "issues.fields.security", "issues.fields.parent", "Automated Status"}),
// Expand parent issue information
ExpandedParent = Table.ExpandRecordColumn(ExpandedIssueFields, "issues.fields.parent",
{"id", "key", "self", "fields"},
{"issues.fields.parent.id", "issues.fields.parent.key", "issues.fields.parent.self", "issues.fields.parent.fields"}),
ExpandedParentFields = Table.ExpandRecordColumn(ExpandedParent, "issues.fields.parent.fields",
{"summary", "status", "priority", "issuetype"},
{"issues.fields.parent.fields.summary", "issues.fields.parent.fields.status", "issues.fields.parent.fields.priority", "issues.fields.parent.fields.issuetype"}),
ExpandedParentIssueType = Table.ExpandRecordColumn(ExpandedParentFields, "issues.fields.parent.fields.issuetype",
{"self", "id", "description", "iconUrl", "name", "subtask", "avatarId", "hierarchyLevel"},
{"issues.fields.parent.fields.issuetype.self", "issues.fields.parent.fields.issuetype.id", "issues.fields.parent.fields.issuetype.description", "issues.fields.parent.fields.issuetype.iconUrl", "issues.fields.parent.fields.issuetype.name", "issues.fields.parent.fields.issuetype.subtask", "issues.fields.parent.fields.issuetype.avatarId", "issues.fields.parent.fields.issuetype.hierarchyLevel"}),
// Expand project information
ExpandedProject = Table.ExpandRecordColumn(ExpandedParentIssueType, "issues.fields.project",
{"self", "id", "key", "name", "projectTypeKey", "simplified", "avatarUrls"},
{"issues.fields.project.self", "issues.fields.project.id", "issues.fields.project.key", "issues.fields.project.name", "issues.fields.project.projectTypeKey", "issues.fields.project.simplified", "issues.fields.project.avatarUrls"}),
// Expand issue type information
ExpandedIssueType = Table.ExpandRecordColumn(ExpandedProject, "issues.fields.issuetype",
{"self", "id", "description", "iconUrl", "name", "subtask", "avatarId", "hierarchyLevel"},
{"issues.fields.issuetype.self", "issues.fields.issuetype.id", "issues.fields.issuetype.description", "issues.fields.issuetype.iconUrl", "issues.fields.issuetype.name", "issues.fields.issuetype.subtask", "issues.fields.issuetype.avatarId", "issues.fields.issuetype.hierarchyLevel"}),
// Expand assignee information
ExpandedAssignee = Table.ExpandRecordColumn(ExpandedIssueType, "issues.fields.assignee",
{"self", "accountId", "emailAddress", "avatarUrls", "displayName", "active", "timeZone", "accountType"},
{"issues.fields.assignee.self", "issues.fields.assignee.accountId", "issues.fields.assignee.emailAddress", "issues.fields.assignee.avatarUrls", "issues.fields.assignee.displayName", "issues.fields.assignee.active", "issues.fields.assignee.timeZone", "issues.fields.assignee.accountType"}),
// Expand resolution information
ExpandedResolution = Table.ExpandRecordColumn(ExpandedAssignee, "issues.fields.resolution",
{"self", "id", "description", "name"},
{"issues.fields.resolution.self", "issues.fields.resolution.id", "issues.fields.resolution.description", "issues.fields.resolution.name"}),
// First round of column renaming
RenamedColumns1 = Table.RenameColumns(ExpandedResolution, {
{"issues.id", "Issue ID"},
{"issues.self", "Issue API Link"},
{"issues.key", "Issue Key"},
{"issues.fields.assignee.displayName", "Issue Assignee Name"},
{"issues.fields.issuetype.name", "Issue Type"}
}),
// Transform labels array to comma-separated text
ExtractedLabels = Table.TransformColumns(RenamedColumns1, {
"issues.fields.labels", each Text.Combine(List.Transform(_, Text.From), ","), type text
}),
// Second round of column renaming
RenamedColumns2 = Table.RenameColumns(ExtractedLabels, {
{"issues.fields.labels", "Issue Labels"},
{"issues.fields.project.key", "Project Key"},
{"issues.fields.project.id", "Project ID"},
{"issues.fields.project.name", "Project Name"},
{"issues.fields.project.projectTypeKey", "Project Type"},
{"issues.fields.summary", "Issue Summary"}
}),
// Expand priority information
ExpandedPriority = Table.ExpandRecordColumn(RenamedColumns2, "issues.fields.priority",
{"self", "iconUrl", "name", "id"},
{"issues.fields.priority.self", "issues.fields.priority.iconUrl", "issues.fields.priority.name", "issues.fields.priority.id"}),
// Third round of column renaming
RenamedColumns3 = Table.RenameColumns(ExpandedPriority, {
{"issues.fields.priority.name", "Issue Priority"},
{"issues.fields.created", "Issue Created At"}
}),
// Process datetime - split by timezone delimiter
SplitDateTime = Table.SplitColumn(RenamedColumns3, "Issue Created At",
Splitter.SplitTextByDelimiter("+", QuoteStyle.Csv),
{"Issue Created At.1", "Issue Created At.2"}),
// Convert data types
ChangedTypes = Table.TransformColumnTypes(SplitDateTime, {
{"Issue Created At.1", type datetime},
{"Issue Created At.2", Int64.Type}
}),
// Clean up datetime columns
RenamedDateTime = Table.RenameColumns(ChangedTypes, {{"Issue Created At.1", "Issue Created"}}),
RemovedTimezoneColumn = Table.RemoveColumns(RenamedDateTime, {"Issue Created At.2"}),
// Rename parent issue columns
RenamedParentColumns = Table.RenameColumns(RemovedTimezoneColumn, {
{"issues.fields.parent.id", "Issue Parent ID"},
{"issues.fields.parent.key", "Issue Parent Key"},
{"issues.fields.parent.self", "Issue Parent Api Link"},
{"issues.fields.parent.fields.summary", "Issue Parent Summary"}
}),
// Expand parent status information
ExpandedParentStatus = Table.ExpandRecordColumn(RenamedParentColumns, "issues.fields.parent.fields.status",
{"self", "description", "iconUrl", "name", "id", "statusCategory"},
{"issues.fields.parent.fields.status.self", "issues.fields.parent.fields.status.description", "issues.fields.parent.fields.status.iconUrl", "issues.fields.parent.fields.status.name", "issues.fields.parent.fields.status.id", "issues.fields.parent.fields.status.statusCategory"}),
// Expand current issue status information
ExpandedStatus = Table.ExpandRecordColumn(ExpandedParentStatus, "issues.fields.status",
{"self", "description", "iconUrl", "name", "id", "statusCategory"},
{"issues.fields.status.self", "issues.fields.status.description", "issues.fields.status.iconUrl", "issues.fields.status.name", "issues.fields.status.id", "issues.fields.status.statusCategory"}),
// Final expansion - automated status
ExpandedAutomatedStatus = Table.ExpandRecordColumn(ExpandedStatus, "Automated Status",
{"value"},
{"Automated Status"}),
// Remove unnecessary columns from final result
CleanedData = Table.RemoveColumns(ExpandedAutomatedStatus, {
"issues.fields.assignee.avatarUrls",
"issues.fields.votes",
"issues.fields.status.statusCategory",
"issues.fields.creator",
"issues.fields.components",
"issues.fields.reporter",
"issues.fields.progress",
"issues.fields.project.avatarUrls",
"issues.fields.watches",
"issues.fields.description",
"issues.fields.fixVersions",
"issues.fields.versions",
"issues.fields.parent.fields.status.statusCategory",
"issues.fields.parent.fields.priority"
})
in
CleanedData,
// Call the function with the original parameters
Result = GetJiraData("OTOM", "ATATT3xFfGF0D3-T9cQuGzvr5jj2WPrh6wjLpybSzp5uu9-7P6zUy53uK9lWhIraZlfv62n2f3t69jUud8b4lxRHYXSD-5QdS3rV99avlCyOHVtTdOfEQ539UKPlK9jesrNT3wkrzyE3TMMDSX4s-OYilIomU20NS_4fDTAi6_1ulZYxhtdT0Ek=4E619766", "Hub in the Box"),
#"Renamed Columns" = Table.RenameColumns(Result,{{"Issue Key", "Jira Number"}, {"Issue Assignee Name", "Assignee"}, {"issues.fields.assignee.emailAddress", "Assignee EmailAddress"}, {"issues.fields.assignee.timeZone", "Assignee TimeZone"}, {"issues.fields.status.name", "Status"}}),
#"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"Project ID", "Project Key", "Project Name", "Project Type", "Jira Number", "Assignee", "Issue Type", "Status", "Assignee TimeZone", "Assignee EmailAddress", "issues.expand", "Issue ID", "Issue API Link", "issues.fields.resolution.self", "issues.fields.resolution.id", "issues.fields.resolution.description", "issues.fields.resolution.name", "issues.fields.aggregatetimeoriginalestimate", "issues.fields.assignee.self", "issues.fields.assignee.accountId", "issues.fields.assignee.active", "issues.fields.assignee.accountType", "issues.fields.issuetype.self", "issues.fields.issuetype.id", "issues.fields.issuetype.description", "issues.fields.issuetype.iconUrl", "issues.fields.issuetype.subtask", "issues.fields.issuetype.avatarId", "issues.fields.issuetype.hierarchyLevel", "issues.fields.timeestimate", "issues.fields.status.self", "issues.fields.status.description", "issues.fields.status.iconUrl", "issues.fields.status.id", "issues.fields.aggregatetimeestimate", "issues.fields.timespent", "issues.fields.aggregatetimespent", "issues.fields.workratio", "Issue Labels", "issues.fields.project.self", "issues.fields.project.simplified", "issues.fields.resolutiondate", "issues.fields.updated", "issues.fields.timeoriginalestimate", "Issue Summary", "issues.fields.statuscategorychangedate", "issues.fields.priority.self", "issues.fields.priority.iconUrl", "Issue Priority", "issues.fields.priority.id", "Issue Created", "issues.fields.security", "Issue Parent ID", "Issue Parent Key", "Issue Parent Api Link", "Issue Parent Summary", "issues.fields.parent.fields.status.self", "issues.fields.parent.fields.status.description", "issues.fields.parent.fields.status.iconUrl", "issues.fields.parent.fields.status.name", "issues.fields.parent.fields.status.id", "issues.fields.parent.fields.issuetype.self", "issues.fields.parent.fields.issuetype.id", "issues.fields.parent.fields.issuetype.description", "issues.fields.parent.fields.issuetype.iconUrl", "issues.fields.parent.fields.issuetype.name", "issues.fields.parent.fields.issuetype.subtask", "issues.fields.parent.fields.issuetype.avatarId", "issues.fields.parent.fields.issuetype.hierarchyLevel", "Automated Status"}),
#"Renamed Columns1" = Table.RenameColumns(#"Reordered Columns",{{"Issue Created", "Created"}, {"issues.fields.updated", "Updated"}}),
#"Reordered Columns1" = Table.ReorderColumns(#"Renamed Columns1",{"Project ID", "Project Key", "Project Name", "Project Type", "Jira Number", "Assignee", "Issue Type", "Status", "Created", "Updated", "Assignee TimeZone", "Assignee EmailAddress", "issues.expand", "Issue ID", "Issue API Link", "issues.fields.resolution.self", "issues.fields.resolution.id", "issues.fields.resolution.description", "issues.fields.resolution.name", "issues.fields.aggregatetimeoriginalestimate", "issues.fields.assignee.self", "issues.fields.assignee.accountId", "issues.fields.assignee.active", "issues.fields.assignee.accountType", "issues.fields.issuetype.self", "issues.fields.issuetype.id", "issues.fields.issuetype.description", "issues.fields.issuetype.iconUrl", "issues.fields.issuetype.subtask", "issues.fields.issuetype.avatarId", "issues.fields.issuetype.hierarchyLevel", "issues.fields.timeestimate", "issues.fields.status.self", "issues.fields.status.description", "issues.fields.status.iconUrl", "issues.fields.status.id", "issues.fields.aggregatetimeestimate", "issues.fields.timespent", "issues.fields.aggregatetimespent", "issues.fields.workratio", "Issue Labels", "issues.fields.project.self", "issues.fields.project.simplified", "issues.fields.resolutiondate", "issues.fields.timeoriginalestimate", "Issue Summary", "issues.fields.statuscategorychangedate", "issues.fields.priority.self", "issues.fields.priority.iconUrl", "Issue Priority", "issues.fields.priority.id", "issues.fields.security", "Issue Parent ID", "Issue Parent Key", "Issue Parent Api Link", "Issue Parent Summary", "issues.fields.parent.fields.status.self", "issues.fields.parent.fields.status.description", "issues.fields.parent.fields.status.iconUrl", "issues.fields.parent.fields.status.name", "issues.fields.parent.fields.status.id", "issues.fields.parent.fields.issuetype.self", "issues.fields.parent.fields.issuetype.id", "issues.fields.parent.fields.issuetype.description", "issues.fields.parent.fields.issuetype.iconUrl", "issues.fields.parent.fields.issuetype.name", "issues.fields.parent.fields.issuetype.subtask", "issues.fields.parent.fields.issuetype.avatarId", "issues.fields.parent.fields.issuetype.hierarchyLevel", "Automated Status"})
in
#"Reordered Columns1"
----------------------Ends ----------------------------