cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.