Hi,
Hi there,
Below is a function that was apparently previously working with Insight to export data to excel.
I have changed the Uri basically to match what the API says it should be but I am continually getting an error about and 'activationId' but not sure what to do to fix it.
Function Export-InsightWarrantyToExcel {
param(
[string]$ExcelFile
)
$AccessToken = "MY BEARER TOKEN"
$workspaceId = "WORKSPACE ID"
# Get the current date and add 60 days to it
$Date60DaysFromNow = (Get-Date).AddDays(60)
#$Uri = "https://api.atlassian.com/jsm/assets/workspace/{workspaceId}/v1/aql/objects?Warranty Expiry Date=$($Date60DaysFromNow.ToString("yyyy-MM-dd"))"
$Uri = "https://api.atlassian.com/jsm/assets/workspace/{workspaceId}/v1/aql/objects"
$Objects = Invoke-RestMethod -Uri $Uri -Headers @{Authorization = "Bearer $AccessToken"}
# Convert the objects to an array of objects with properties that match the Excel column names
$Data = $Objects.data | Select-Object Name, 'Warranty Expiry Date'
# Export the data to Excel
$Excel = New-Object -ComObject Excel.Application
$Excel.Visible = $False
$Workbook = $Excel.Workbooks.Add()
$Sheet = $Workbook.Sheets.Item(1)
#$Sheet.Cells.Item(1,1) = "id"
$Sheet.Cells.Item(1,2) = "Name"
$Sheet.Cells.Item(1,3) = "Warranty Expiry Date"
$Data | ForEach-Object {
$Row = $_.PSObject.Properties["Name"].Value
#$Sheet.Cells.Item($Row+1,1) = $_.id
$Sheet.Cells.Item($Row+1,2) = $_.Name
$Sheet.Cells.Item($Row+1,3) = $_.'Warranty Expiry Date'
}
$Workbook.SaveAs($ExcelFile)
$Excel.Quit()
}
here is what I use to fire the command.
Export-InsightWarrantyToExcel -ExcelFile "C:\temp\Warranty.xlsx"
I am continually getting bounced here;
Invoke-RestMethod : {"code":400,"message":"activationId is not provided"}
Thanks