Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
Laila92
Helper V
Helper V

connecting Powerbi and Jira from M

Hi, I tried looking ina  few topics like :https://community.powerbi.com/t5/Desktop/Connecting-Jira-to-Power-BI-using-the-Web-API/td-p/838130

 

But i can not get my code to work.

 

What I have is below:

let 
    BaseUrl = "https://autoleadstar.atlassian.net/rest/api/2/issue/createmeta",
    Credentials = "XXXX@email.com:My_token",
    JiraIDPerPage = 1000,
 
    GetJson = (Url) =>
        let 
            RawData = Web.Contents(Url,[Headers=[Authorization="Basic " & Credentials]]),
            Json    = Json.Document(RawData)
        in  Json,
 
    GetJiraIDCount = () =>
        let Url   = BaseUrl & "&maxResults=0",
            Json  = GetJson(Url),
            Count = Json[#"total"]
        in  Count,
 
    GetPage = (Index) =>
        let Skip  = "&startAt=" & Text.From(Index * JiraIDPerPage),
            Top   = "&maxResults=" & Text.From(JiraIDPerPage),
            Url   = 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),
    #"Expanded Column1" = Table.ExpandRecordColumn(Table, "Column1", {"id", "key", "fields"}, {"Column1.id", "Column1.key", "Column1.fields"})
in
    Table

I get the following error: 
"We couldn't authenticate with the credentials provide. Please try again."

 

Any tips on how to proceed?

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @Laila92 

From your code I think you want to use a REST API as a data source.

Please check whether your access token is correct.

...
Credentials = "XXXX@email.com:My_token",
...
etJson = (Url) =>
        let 
            RawData = Web.Contents(Url,[Headers=[Authorization="Basic " & Credentials]]),

You can try to use web connector in Power BI to connect to your data source. You can add your authentication and other parameters you need in HTTP request header parameters in Advancd.

1.png

For reference: Using a REST API as a data source

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

View solution in original post

3 REPLIES 3
ltopchyi
Helper III
Helper III

Hi @Laila92 

You can consider using Power BI Connector for Jira as one more way to solve your issue.

Liubov

Laila92
Helper V
Helper V

I was able to connect, but am only getting an empty table back. Any idea why that is?

v-rzhou-msft
Community Support
Community Support

Hi @Laila92 

From your code I think you want to use a REST API as a data source.

Please check whether your access token is correct.

...
Credentials = "XXXX@email.com:My_token",
...
etJson = (Url) =>
        let 
            RawData = Web.Contents(Url,[Headers=[Authorization="Basic " & Credentials]]),

You can try to use web connector in Power BI to connect to your data source. You can add your authentication and other parameters you need in HTTP request header parameters in Advancd.

1.png

For reference: Using a REST API as a data source

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

Top Solution Authors