Power BI

Here's an example to do a GET business units call using Power Query:

Copy
Copied
let
 clientId = "your-client-id",
 clientSecret = "your-client-secret",
 scopes = "your-scopes",

 tokenUrl = "https://api.hcssapps.com/identity/connect/token",

 getTokenRequest = Web.Contents(tokenUrl,
     [
         Headers = [#"Content-Type"="application/x-www-form-urlencoded;charset=UTF-8"],
         Content = Text.ToBinary("client_id=" & clientId & "&client_secret=" & clientSecret & "&scope=" & scopes & "&grant_type=client_credentials")
     ]
 ),

 formatTokenResponseAsJson = Json.Document(getTokenRequest),
 accessToken = formatTokenResponseAsJson[access_token],
 authorizationHeader = "Bearer " & accessToken,

 getBusinessUnitsRequest = Web.Contents("https://api.hcssapps.com/setups/api/v1/BusinessUnit",
     [
         Headers = [#"Authorization"=authorizationHeader]
     ]
 ),

 formatBusinessUnitsResponseAsJson = Json.Document(getBusinessUnitsRequest),
 businessUnitsTable = Table.FromList(formatBusinessUnitsResponseAsJson, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
 expandColumn = Table.ExpandRecordColumn(businessUnitsTable, "Column1", {"id", "code", "description"}, {"id", "code", "description"})
in
 expandColumn

 

If you're stuck, please contact us and we'll help you out.