Hi @Nick Bowler ,
I use Python. Anyway I ask copilot to translate the original LeanIX example:
# Get environment variables
$LEANIX_API_TOKEN = $env:LEANIX_API_TOKEN
$LEANIX_SUBDOMAIN = $env:LEANIX_SUBDOMAIN
$LEANIX_GRAPHQL_URL = "https://$LEANIX_SUBDOMAIN.leanix.net/services/pathfinder/v1/graphql"
$LEANIX_OAUTH2_URL = "https://$LEANIX_SUBDOMAIN.leanix.net/services/mtm/v1/oauth2/token"
function Get-LeanIXAccessToken {
if (-not $LEANIX_API_TOKEN) {
throw "A valid token is required"
}
$body = @{
grant_type = "client_credentials"
}
$response = Invoke-RestMethod -Method Post -Uri $LEANIX_OAUTH2_URL -Body $body -Authentication Basic -Credential (New-Object System.Management.Automation.PSCredential("apitoken", (ConvertTo-SecureString $LEANIX_API_TOKEN -AsPlainText -Force)))
return $response.access_token
}
function Invoke-LeanIXQuery {
$access_token = Get-LeanIXAccessToken
$graphql_query = @"
{
allFactSheets(factSheetType: Application) {
totalCount
edges {
node {
id
name
}
}
}
}
"@
$headers = @{
Authorization = "Bearer $access_token"
Content-Type = "application/json"
}
$body = @{
query = $graphql_query
} | ConvertTo-Json -Depth 3
$response = Invoke-RestMethod -Method Post -Uri $LEANIX_GRAPHQL_URL -Headers $headers -Body $body
$response | ConvertTo-Json -Depth 5
}
Invoke-LeanIXQuery
I got usually good results, So I learned pyspark. Anyway it is worth as try.
Best regards,
Carsten
Hi there!
I’ve just uploaded some code that might help you onto github. It’s really rough so apologies in advance.
fletcherg/leanix-api-powershell: Basic Powershell to interact with LeanIX API
What system are you looking to integrate? Would be keen to connect and understand more, or if you’re willing to compare sync scripts 
Thanks! I havent has a chance to look at the code yet -- but all I really needed was something to get us started.
We are planning to pull in data from tenable. In leanIX we want to have some basic information on our servers -- Name, OS, who is responsible for the server, and link to applications. It will be a couple of months till we get around to integrating with tenable.