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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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