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


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

I can retrieve my own licences :



$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

$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

$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.