Get Campaign Report's ID through API

Hi. Does the API allow me to get Campaign Report’s ID? If not, what is the work around to get Report ID? Thanks.

1 Like

Hi @ihar512 -

You certainly can get Campaign Report IDs. These however are older non-public APIs.

The API to get the Campaign Reports is:

GET {api-url}/cms/campaigns/campaigns/{campaignId}/reports?campaignId={campaignId}&page=1&start=0&limit=25

(I am not sure why the above API has both the campaignId as a path parameter and a query parameter, but it does according to our product)

From here you’ll get back a response that looks something like this:

[
  {
    "created":1627073459991,
    "currentDate":1627073460067,
    "name":"Campaign Status Report",
    "taskResultId":"2c9180877acafa47017ad522b717447b",
    "status":null
  },
  {
    "created":1627073460517,
    "currentDate":1627073460596,
    "name":"Certification Signoff Report",
    "taskResultId":"2c9180847acafa46017ad522b92542f6",
    "status":null
  },
  {
    "created":1627073460995,
    "currentDate":1627073461066,
    "name":"Campaign Composition Report",
    "taskResultId":"2c9180847acafa45017ad522bb024375",
    "status":null
  }
]

If you want to get a report you should be able to call:

GET {api-url}/cc/api/report/get/{taskResultId}?format=csv&name={name}

Note: As a trick, you can see these APIs in action by going to your browser’s Developer Tools and watching the Network requests when interacting in the UI. You can see the calls and payloads there.

Hope this helps!

1 Like

Hi Neil, thank you for the quick follow up. So I tried the method you provided to get the Campaign Report IDs, I ended up getting ‘{“error”:“Unable to route request”}’ in response and 401 error code. I provided the same Bearer token I used to get the campaignID in the header, does a new Bearer token is needed? Seems like it’s saying lack of valid authentication credentials.

@ihar512 Were you ever able to figure out the [{“error”:“Unable to route request”}’ in response and 401 error code] issue?
I’m having a similar issue with a Bearer token being invalid.

Thanks,
Chris

Hey Chris,
Did you use client credentials from security settings or you used personal access token to generate bearer token?

Hey @chirag.patel,
I tried both. I’m using Postman and when I generate the token using either set of values, I get that error.
When I get the Bearer token from inspecting the Network tab in chrome for the Entitlements tab for the source and use that it works fine.

I’m returning the list of Entitlements using the API call: /ears/entitlements-v3/entitlements
Do I have to do something different for that API? I use the same OAUTH tokens for the V3 and Beta API calls without issues.

Thanks,
Chris

1 Like

Hey @chrisp, no I have not figured it out yet. Following this thread.

@ihar512,

The most likely reason you are seeing a 401 with {“error”:“Unable to route request”} is because the endpoint you are trying to reach can only be called with a token that is generated by the UI. /cc, /v2, /beta, and /v3 APIs are on a different routing architecture than our internal APIs and can be called using the PAT or OAuth2 generated tokens.

I do see that there is a /beta endpoint for getting campaign reports. Does this work for your needs?

Hey @ihar512, was the above able to resolve your 404 issue? We would love to hear an update!

@michael.ellis @chrisp
Hey all. After digging through the browser developer tools I am now able to get the campaign report CSV file by using the taskResultId. Here are the steps

  1. GET {api-url}/cc/api/campaign/getReports?campaignId={campaignId}
  2. PAYLOAD = GET {api-url}/cc/api/report/get/{taskResultId}?format=csv&name={report_name}
  3. POST {api-url}/security/signUrl with PAYLOAD
  4. Use the response’s url from step 3 to download report CSV

But once again, the API to get the campaign reports still doesn’t work. I hope the official API will support this in the near future.

Thank you for sharing that update, @ihar512