Forum Discussion

Coyote34's avatar
Coyote34
Frequent Visitor
2 years ago
Solved

Jira API in Data Flow error:

Hi there!   I am trying to create a dataflow to load Jira data using follow script   let BaseUrl = "https://********.atlassian.net/rest/api/3/search?jql=project in ('ABC') AND created >= '...
  • Coyote34's avatar
    2 years ago

    HI, guys. 

     

    I wanna share the solution after a lot ogf resource.

     

    let
      request = (startAt) => 
      let
        get = Json.Document(
          Web.Contents(
              "https://yourcompny.atlassian.net",
              [
                Headers=
                  [Authorization="Basic ********************************************** ="],
                  RelativePath = "/rest/api/3/search?" & "jql=project in ('ABC') AND created >= '2024-01-01' AND created < '2025-01-01'" & "&startAt=" & Text.From(startAt) & "&fields=*all&maxResults=" & Text.From(maxResults)
              ]
          )
        )
      in
        get,
      results = request(1),
      #"Converter em tabela" = Table.FromValue(results),
      #"Transformar colunas" = Table.TransformColumnTypes(#"Converter em tabela", {{"Value", type text}}),
      #"Substituir erros" = Table.ReplaceErrorValues(#"Transformar colunas", {{"Value", null}}),
      #"Linhas filtradas" = Table.SelectRows(#"Substituir erros", each ([Name] = "total")),
      #"Tipo de coluna alterado" = Table.TransformColumnTypes(#"Linhas filtradas", {{"Value", Int64.Type}}),
      #"Coluna dividida" = Table.TransformColumns(#"Tipo de coluna alterado", {{"Value", each _ / 100, type number}}),
      #"Arredondado para cima" = Table.TransformColumns(#"Coluna dividida", {{"Value", each Number.RoundUp(_), Int64.Type}}),
      Personalizar = List.Generate(() => 1, each _ <= #"Arredondado para cima"{0}[Value], each _ +1, each request((maxResults * (_ - 1)) + 1)),
      #"Convertido em tabela" = Table.FromList(Personalizar, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
    in
        #"Convertido em tabela"