Getting Campaign Reports .csv (Follow Up)

Hi,

This is a follow-up topic to closed topic “Getting Campaign Reports”. I believe someone mentioned that there would be an option to download campaign reports from the API endpoint. Is this still in the works? The last I saw pertaining to this topic was back in 2022. This feature would be extremely useful.

The current response, feat. fields: lastRunAt, reportType, status, type, id, and name are good to know, but the most useful thing to have would be the actual report .csv or .pdf.

If you are talking about this API get-campaign-reports | SailPoint Developer Community, then yes it still works.

Thank you for your response. My question is about being able to download the .csv or .pdf directly from the API endpoint. Currently, the response just details information about the report, such as its title. This is not what I am seeking.

understood, I don’t think its possible. I am welcome to hear from others.

It’s possible. Here’s how I did it using the IdentityNow PowerShell Modules.
You need to get the ID’s of the in-scope campaigns, which I won’t go into here. But once you have them:

First generate the reports - one call for each report type:

Invoke-IdentityNowRequest -Method POST -URI "https://$($orgName).api.identitynow.com/beta/campaigns/$($_.id)/run-report/CAMPAIGN_COMPOSITION_REPORT" -Headers HeadersV3
Invoke-IdentityNowRequest -Method POST -URI "https://$($orgName).api.identitynow.com/beta/campaigns/$($_.id)/run-report/CAMPAIGN_REMEDIATION_STATUS_REPORT" -Headers HeadersV3
Invoke-IdentityNowRequest -Method POST -URI "https://$($orgName).api.identitynow.com/beta/campaigns/$($_.id)/run-report/CAMPAIGN_STATUS_REPORT" -Headers HeadersV3
Invoke-IdentityNowRequest -Method POST -URI "https://$($orgName).api.identitynow.com/beta/campaigns/$($_.id)/run-report/CERTIFICATION_SIGNOFF_REPORT" -Headers HeadersV3

I introduce a 10-20 second sleep here. That’s probably longer than necessary, but just to safe:

Start-Sleep -Seconds 20

Then loop through the campaigns, generate the file names you want to save the reports as and use something like either or both of the following:

$filePath = "./CampaignReports/$($campaignPathName)$($suffix) - $($_.name).pdf"
Invoke-IdentityNowRequest -Method GET -URI "https://$($orgName).api.identitynow.com/cc/api/report/get/$($_.id)?format=pdf" -Headers HeadersV3 -OutFile $filePath

OR

$filePath = "./CampaignReports/$($campaignPathName)$($suffix) - $($_.name).csv"
$result = Invoke-IdentityNowRequest -Method GET -URI "https://$($orgName).api.identitynow.com/cc/api/report/get/$($_.id)?format=csv" -Headers HeadersV3 
Set-Content -Path $filePath -Value $result
3 Likes

Hi @sailpointuser23 . Did @KevinHarrington 's reply solve your question? If so, can you please mark it as the solution? Thanks!

I am trying to make this work in postman and I cannot figure out the parameters or body to pass.

The url for me is: https://org-sb.api.identitynow.com/cc/api/report/get/b788afb0d3204d85b5a4069f3e254696?format=csv
but where should I pass filepath.

Also this call is not visible in network trace, how did you get it.

Hi @sailpointuser23

I am using typescript SDK to get the customised csv report to track the status in faster way.
Use CertificationsApi to achieve this.

import { AccountsApi, Configuration, Paginator, CertificationsApi,axiosRetry} from "sailpoint-api-client"
export const getCerts = async() => {
    let apiConfig = new Configuration()
    apiConfig.retriesConfig = {
        retries: 4,
        retryDelay: axiosRetry.exponentialDelay,
        onRetry(retryCount, error, requestConfig) {
            console.log(`retrying due to request error, try number ${retryCount}`)
        },
    }
        let api = new CertificationsApi(apiConfig)
        let parameters={
            filters: 'campaign.id eq "<your-campaign-id>"'
        }

Reporting using SDK

Make the call and save the result in a variable, then save the result to the filepath:

$filePath = "./CampaignReports/$($campaignPathName)$($suffix) - $($_.name).csv"
$result = Invoke-IdentityNowRequest -Method GET -URI "https://$($orgName).api.identitynow.com/cc/api/report/get/$($_.id)?format=csv" -Headers HeadersV3 
Set-Content -Path $filePath -Value $result

I got this call before the interface was updated by hitting the F12 key in my browser and going into the “Network” tab, then downloading the reports. It doesn’t show up in the new interface, so I don’t know how you’d find it now if you didn’t already have it.

Can you share curl call or postman http call instead of this one , that’s what I am looking for.

The call is just a straightforward get. There’s nothing in the call that references a file to output to. I’m using a script to make the call and store the result in a variable, then I output the result into a csv file.

curl --location 'https://<instance>api.identitynow.com/cc/api/report/get/<id>?format=csv' \
--header 'Authorization: Bearer <Bearer Token>

I am getting 404 in postman for this call after following same steps mentioned by you. I am not sure if it’s just me , anyone else following this thread can confirm this behaviour.

Hi @chirag_patel

You dont pass the filepath or filename, the response in postman is the CSV report, you have to save the result as a csv file

GET 'https://mytenant.api.identitynow.com/cc/api/report/get/011b6d9f22854604857eda0894f9605b?format=csv' --header 'Content-Type: text/csv'

Result (example of “Certification Signoff Report”):

Name,Reviewer,Activated,First Action Date,Sign Off Date,Owner
Identity Access Review for Test Manager,,"10/23/23, 6:18:29 AM",,,Test Manager
Identity Access Review for TESTuser Hong,,"10/23/23, 6:18:29 AM",,,TESTuser Hong
Identity Access Review for David Zoom,,"10/23/23, 6:18:30 AM",,,David Zoom
...

Then in postman, you would copy the whole response body, and paste into notepad, and save as csv.

in a script you would save the response to some variable, then write that variable to file

responseBody = IDNAPI.get("#{$config['baseUrl']}/cc/api/report/get/#{report['id']}?format=csv")
writeToFile(responseBody.body,filePath,fileName)

I understand the concept :slight_smile: but seems like I am getting 404 in postman. I tried in both sandbox and prod and with different types of report. Getting same 404 in postman.

Hi,
404 is not found, so I am guessing the Report ID you are using is not correct.

For a given campaign, you can get the report IDs

GET beta/campaigns/[campaign ID]/reports

Then you get the report IDs

[
    {
        "lastRunAt": "2023-10-23T22:14:40.979Z",
        "reportType": "CAMPAIGN_COMPOSITION_REPORT",
        "status": "SUCCESS",
        "type": "REPORT_RESULT",
        "id": "d24f29d9d03a4fe993e8f763c24b3a3c",
        "name": "Campaign Composition Report"
    },
    {
        "lastRunAt": "2023-10-23T22:14:55.273Z",
        "reportType": "CAMPAIGN_STATUS_REPORT",
        "status": "SUCCESS",
        "type": "REPORT_RESULT",
        "id": "050b6d9f22854604857eda0894f9605b",
        "name": "Campaign Status Report"
    },

Note that reports will not necessarily have the most recent data - you need to call the run-report first (for each type) - Then get the report IDs (above)

eg

POST beta/campaigns/[Campaign ID]/run-report/CAMPAIGN_STATUS_REPORT

1 Like

Thanks @jrossicare for clarifying, In cc api call I was using campaign id instead of callign out specific report id.
Thanks everyone for the help

Hi @chirag_patel have a look at this, should you even not want to use Postman, there are other alternatives. Also if you are not already aware, you need to make sure you get the latest taskresultid prior to running the Campaign status report. As otherwise you will be downloading the previous data every time. https://community.sailpoint.com/t5/IdentityNow-Forum/Leveraging-Microsoft-Power-Automate-to-enhance-IdentityNow/td-p/232373

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.