Search code examples
powerbiblackduck

BlackDuck and Power BI


I would like to connect from Power BI to BlackDuck using Rest API.

Initially, I would like to do everything using Power Query. I just started exploring the possibilities of how to retrieve data without using a PostgreSQL database of the BlackDuck.

Maybe you had an experience of how to authenticate BlackDuck? Maybe you have such experience and can share it?


Solution

  • I tested using API, but the easiest way was connected to PostgreSQL ( synopsis support helped with it)

    About API

    1. need to get bearer token

    create function (ex name GetToken):

        ()=>
        let
        
        url = "https://XXX.blackduck.com/api/tokens/authenticate",
        headers = [
           #"Accept" = "application/vnd.blackducksoftware.user-4+json",
           #"Authorization"= token XXXXXXXXXXX
           
           ],
        
        PostData=Json.FromValue([Authorization =  prToken]), 
        
        response = Web.Contents( url, 
                  [ Headers = headers,
                    Content = PostData]),
        
        Data = Json.Document(response),
        
        access_token="Bearer "&Data[bearerToken]
        
        
        in
        access_token
    
    // where XXXXXXXXXXX  is your token from BlackDuck 
    

    it helps you to get Bearer token

    1. as example to get information about project

      let

       Source = Json.Document(Web.Contents("https://xxxxx.app.blackduck.com/api/projects", 
       [Headers=[Accept="application/vnd.blackducksoftware.project-detail-4+json",
       Authorization = GetToken()]]))
      

      in Source[totalCount]