I’m currently setting up Productboard with Gainsight CS for feature requests to be logged within Gainsight CS, and the instructions (https://support.gainsight.com/gainsight_nxt/Product_Requests/Product_Requests_-_Productboard_Integration/Configure_Product_Requests#Company_Mapping) say to log a support ticket for the list of companies.
I didn’t want to do that, so I wrote a quick PowerShell script to export the information with the API key I already had from completing the connector configuration. I wanted to share it here in case anyone else needs it in future.
# Set the base URL for the API with placeholders for pageLimit and pageOffset
$base_url = "https://api.productboard.com/companies?pageLimit=100&pageOffset=0"
# Authorization Token (replace with your actual token)
$auth_token = "XXX"
# Variable to store the current URL (start with the base URL)
$current_url = $base_url
# Variable to control the pagination loop
$has_more_data = $true
# Array to store all data
$data_array = @()
# Loop through the pagination
while ($has_more_data) {
Write-Host "Fetching data from: $current_url"
# Make the API request using Invoke-RestMethod
$response = Invoke-RestMethod -Uri $current_url `
-Headers @{ "Authorization" = "Bearer $auth_token"; "Content-Type" = "application/json" }
# Extract the data from the response and add it to the array
if ($response -ne $null -and $response.data -ne $null) {
# Extract relevant fields from the "data" array
$data_array += $response.data | Select-Object id, name, domain, description, sourceOrigin, sourceRecordId
}
# Check if there is a "next" link to continue paginating
if ($response.links.next -eq $null) {
$has_more_data = $false
Write-Host "No more pages."
} else {
# Update the URL for the next request using the next page link
$current_url = $response.links.next
}
}
# Export the combined data to a CSV file
if ($data_array.Count -gt 0) {
$data_array | Export-Csv -Path "companies_data.csv" -NoTypeInformation
Write-Host "Data exported to companies_data.csv"
} else {
Write-Host "No data to export."
}
Hope it helps!