API and Powershell -Get

Hi,
We have been given the API to get the data. I am wondering if anyone has written a a Powershell or Python script that they would be prepared to send me the basics of to save me reinventing the wheel and it ends up being a square wheel?

Regards

Doug

Hi Doug,

I’ve got some PowerShell scripts that I have created for you, these are basic and can be used in any way you want.

If you want to load the data without the use of Saved Report you can use the normal Report API and if you want to use a Saved Report with filters and columns set you can use the Saved Report API

Be sure to get your API Key from the Platform area and if you need the Report GUID you can get that by clicking the 3 dots on the report in your list and select ‘More Info’, the box at the bottom will contain your Report GUID

Report API Script:

$Domain = "example.com"    <# The domain of the converse server e.g netcall.com, do not include https #>
$PartitionID = "3"       <# The Partition ID being used should be the one as the API Key #>
$GroupID = "3"           <# The Group ID you want the data from #>
$ReportType = "interactions" <# Can only either be 'interactions' or 'auditlog' #>
$StartDate = "2020-07-16"    <# Must be in the format yyyy-mm-dd #>
$EndDate = "2020-07-16"      <# Must be in the format yyyy-mm-dd #>

$Url = "https://$Domain/api/Liberty/2/partitions/$PartitionID/acd/groups/$GroupID/report?type=$ReportType&startdate=$StartDate&enddate=$EndDate"

$Headers = @{
    'Authorization' = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' <# Place your API key here #>
}

$Response = Invoke-RestMethod -Method 'GET' -Uri $Url -Headers $Headers

<# The Response variable now contains all the data and can be used however you want from here #>

$Response.Report | Out-File ReportOutput.csv <# Example of taking the report output into a CSV file #>

Saved Report API Script:

$Domain = "example.com"    <# The domain of the converse server e.g netcall.com, do not include https #>
$PartitionID = "3"       <# The Partition ID being used should be the one as the API Key #>
$ReportGUID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" <# The Report GUID taken from the Saved Report page #>

$Url = "https://$Domain/api/Liberty/2/Partitions/$PartitionID/acd/SavedReports/$ReportGUID"

$Headers = @{
    'Authorization' = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' <# Place your API key here #>
}

$Response = Invoke-RestMethod -Method 'GET' -Uri $Url -Headers $Headers

<# The Response variable now contains all the data and can be used however you want from here #>

$Response.Report | Out-File ReportOutput.csv <# Example of taking the report output into a CSV file #>

If you have any issues with either of those, let me know and I’ll help you out with them.

Kind regards,
Josh

1 Like