Trying to retrieve all licence for all of our customers with API

Hello,

i'm a french partner and i want to retrieve all licences for all my custromers through API

I can retrieve my own licences :

$api='https://api.deu.cloud.watchguard.com/rest'
$apikey=*****
$accessID=***
$pwd=***
$auth="$($accessid):$pwd"

Authentication

$Header =@{"Authorization" = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("$auth"));"Accept" = "application/json"}
$token=Invoke-RestMethod -Method POST -uri $authURL -Headers $Header -body 'grant_type=client_credentials&scope=api-access'

$authtoken="$($token.token_type) $($token.access_token)"

retrieve licences

$licencesURL="$api/endpoint-security/management/api/v1/accounts/ACC-xxx/licenses"
$Header =@{"WatchGuard-API-Key" = "$apikey";"Content-Type" = "application/json";"Accept" = "application/json";"Authorization" = "$authtoken"}
Invoke-RestMethod -Method GET -uri $licencesURL -Headers $Header

To retrieve licences for a customer i understand that i need to create a new authentication token with the customer 'audience'

To retrieve 'audience' of one of my customer i use the audiances API

$audienceURL="$api/platform/authorization/v1/audiences"
$Header =@{"WatchGuard-API-Key" = "$apikey";"Content-Type" = "application/json";"Accept" = "application/json";"Authorization" = "$authtoken"}
$Body = @{accountId = 'WGC-2-**************'}
Invoke-RestMethod -Method POST -uri $audienceURL -Headers $Header -Body $Body

but i have an error 500 message

Invoke-RestMethod : {"type": "about:blank", "status": 500, "title": "Internal Server Error", "detail": "Server got itself in trouble"}
At line:4 char:1

  • Invoke-RestMethod -Method POST -uri $audienceURL -Headers $Header -Bo ...
  • ~~~~~~~~~~~~~~~~~
    • CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    • FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

any help ?

Sign In to comment.