Forum Discussion
Trying to connect to an API
- Anonymous3 years ago
Hi Anonymous - I start by creating an API token following these instuctions: Manage API tokens for your Atlassian account | Atlassian Support. When it comes to using the Token, there are two options for extracting JIRA data:
- Download the CSV for Filters by using the Link.
let Source = Csv.Document( Web.Contents("https://######.atlassian.net/sr/jira.issueviews:searchrequest-csv-all-fields/{id####}/SearchRequest-{id####}.csv"), [Delimiter=",", Encoding=65001, QuoteStyle=QuoteStyle.Csv] ), #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]) in #"Promoted Headers"Note this example would store a data source connection for the fully specified csv file url. You can make this relative path.
This provide a big flat csv table with single row for each issue. While this is good, it is not great for columns with multiple values. If you have 3 watchers for example, there will be 3 columns (watcher, watcher2, watcher3).
- Use the API - The Jira Cloud platform REST API (atlassian.com)
This is an example for the API call.
let #"JIRA Rest API URL Path" = "https://######.atlassian.net/rest/api/3/", #"Relative Path" = "/project/search", #"Max Results Per API Call" = 50, #"Initial API Call" = Web.Contents( #"JIRA Rest API URL Path", [ RelativePath=#"Relative Path", Headers=[Accept="application/json"], Query=[startAt="0"] ] ), #"Open Initial API Call" = Json.Document(#"Initial API Call"), #"Get Total Items" = #"Open Initial API Call"[total], #"Number of API Calls" = Number.IntegerDivide(#"Get Total Items", #"Max Results Per API Call") + 1, #"Run API Calls" = let #"Start At List" = List.Generate(() => 0, each _ < #"Number of API Calls" * 50 , each _ + 50 ), #"Call API" = List.Transform( #"Start At List" , each Web.Contents( #"JIRA Rest API URL Path", [ RelativePath=#"Relative Path", Headers=[Accept="application/json"], Query=[startAt=Text.From(_)] ]) ), #"Open Json" = List.Transform( #"Call API" , each Json.Document(_) ), #"Get values" = List.Transform( #"Open Json" , each _[values] ), #"Get Lists" = List.Combine(#"Get values"), #"Converted to Table" = Table.FromList(#"Get Lists", Splitter.SplitByNothing(), type table[Records to Expand=Record.Type], null, ExtraValues.Error) in #"Converted to Table",To use this call the following data source credentials are required for "https://######.atlassian.net/rest/api/3/"
Hi Anonymous - I start by creating an API token following these instuctions: Manage API tokens for your Atlassian account | Atlassian Support. When it comes to using the Token, there are two options for extracting JIRA data:
- Download the CSV for Filters by using the Link.
let
Source =
Csv.Document(
Web.Contents("https://######.atlassian.net/sr/jira.issueviews:searchrequest-csv-all-fields/{id####}/SearchRequest-{id####}.csv"),
[Delimiter=",", Encoding=65001, QuoteStyle=QuoteStyle.Csv]
),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true])
in
#"Promoted Headers"
Note this example would store a data source connection for the fully specified csv file url. You can make this relative path.
This provide a big flat csv table with single row for each issue. While this is good, it is not great for columns with multiple values. If you have 3 watchers for example, there will be 3 columns (watcher, watcher2, watcher3).
- Use the API - The Jira Cloud platform REST API (atlassian.com)
This is an example for the API call.
let
#"JIRA Rest API URL Path" = "https://######.atlassian.net/rest/api/3/",
#"Relative Path" = "/project/search",
#"Max Results Per API Call" = 50,
#"Initial API Call" = Web.Contents(
#"JIRA Rest API URL Path",
[
RelativePath=#"Relative Path",
Headers=[Accept="application/json"],
Query=[startAt="0"]
]
),
#"Open Initial API Call" = Json.Document(#"Initial API Call"),
#"Get Total Items" = #"Open Initial API Call"[total],
#"Number of API Calls" = Number.IntegerDivide(#"Get Total Items", #"Max Results Per API Call") + 1,
#"Run API Calls" =
let
#"Start At List" = List.Generate(() => 0, each _ < #"Number of API Calls" * 50 , each _ + 50 ),
#"Call API" = List.Transform( #"Start At List" , each
Web.Contents(
#"JIRA Rest API URL Path",
[
RelativePath=#"Relative Path",
Headers=[Accept="application/json"],
Query=[startAt=Text.From(_)]
])
),
#"Open Json" = List.Transform( #"Call API" , each Json.Document(_) ),
#"Get values" = List.Transform( #"Open Json" , each _[values] ),
#"Get Lists" = List.Combine(#"Get values"),
#"Converted to Table" = Table.FromList(#"Get Lists", Splitter.SplitByNothing(), type table[Records to Expand=Record.Type], null, ExtraValues.Error)
in
#"Converted to Table",
To use this call the following data source credentials are required for "https://######.atlassian.net/rest/api/3/"