** Using TDX API with PowerShell and Power BI **

< !!! INTERNAL USE ONLY !!! >
Not for distribution directly to end user

Overview

This article demonstrates how to connect to TDX APIs using PowerShell and Power BI

Audience

Advanced technical staff that need to run reports using the advanced features by using APIs.

Process

PowerShell

Use the following script to get access to information from TDX APIs.

$Headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$postParams = @{BEID='********-****-****-****-************';WebServicesKey='********-****-****-****-************'}
$token = Invoke-WebRequest -Uri "https://ccbcmd.teamdynamix.com/TDWebApi/api/auth/loginadmin" -Method Post -Body $postParams
$Headers.Add("Authorization", ("Bearer " + $token.ToString()))

$Params =@{See https://ccbcmd.teamdynamix.com/TDWebApi for parameter information specific to the API call you're making}
$output = Invoke-WebRequest -Uri "See https://ccbcmd.teamdynamix.com/TDWebApi for URL information specific to the API call you're making" -Headers $Headers -Method Post -Body $Params


$outputlist = $output | ConvertFrom-Json

$outputlist

PowerBI

let
    authbody = [ BEID= "********-****-****-****-************", 
                 WebServicesKey= "********-****-****-****-************"
                 ],
    authheader = [#"Content-Type"= "application/json"],
    authresponse = Web.Contents("https://ccbcmd.teamdynamix.com/TDWebApi/api/auth/loginadmin",[Content=Json.FromValue(authbody),Headers=authheader]),
    authtext = Text.FromBinary(authresponse),
    header = [  #"Authorization"="Bearer "&authtext,
                #"Content-Type"= "application/x-www-form-urlencoded"],
    body = "{ ""Parameter"": ""value""}", See https://ccbcmd.teamdynamix.com/TDWebApi for parameter information specific to the API call you're making
    encodedbody = Text.ToBinary(Uri.BuildQueryString(Json.Document(body))),
    url = "See https://ccbcmd.teamdynamix.com/TDWebApi for URL information specific to the API call you're making",
    response = Web.Contents(url,[Content=encodedbody,Headers=header]),
    Source = Json.Document(response)
in
    Source