Legacy Dev Forum Posts

 View Only

Sign Up

Automatic download of XLSX reports using the API

  • 1.  Automatic download of XLSX reports using the API

    Posted 06-05-2025 18:14

    markoan | 2019-03-22 05:01:21 UTC | #1

    I need to automate downloading some scheduled reports. I'm using the API to get the last successful scheduled report with:

    /api/v2/analytics/reporting/schedules/{scheduleId}/history/latest

    I am able to get the reportUrl but that URL won't let me download the report using a bearer token. What is the correct way to download the file? Is this possible using the client credentials grant?


    tim.smith | 2019-03-22 14:39:00 UTC | #2

    When you make a request to the reportUrl, include the authorization header with your bearer token like any other API request. The response will be a 303 with a Location header. The redirect URL is a direct link to the PDF file and includes a temporal AWS access token; do not include the authorization header on the second request.


    markoan | 2019-03-22 19:43:36 UTC | #3

    Thank you Tim, I forgot to add that to my message before but I did try what you suggest and got a 403 error:

    GET /platform/api/v2/downloads/a0577969 HTTP/1.1 Host: apps.mypurecloud.com Content-Type: application/json Authorization: Bearer [token here] cache-control: no-cache

    { "status": 403, "code": "forbidden", "message": "Access denied for 2a98af7d-10ba-49ad-8cc8-b5a108cf0ea1 for document s3://inin-prod-useast1-analytics/reporting/reports/organizations/abe2b020-4493-4c63-b2e4-84b4901b765a/3690e3e6-f1a3-484f-a0c9-616e0a6194dc.xlsx.", "contextId": "f06b36e3-b654-4118-8e73-e5865067a608", "details": [], "errors": [] }

    Any ideas here?


    tim.smith | 2019-03-22 19:54:15 UTC | #4

    The short answer is that downloading the reports isn't going to work with client credentials at this time; only a request authorized by a user can download the report.

    I'm checking with the reporting team to see if this is a bug or a feature. I'm on Team Bug for this one, but will update here when I have an answer.


    markoan | 2019-03-22 20:07:16 UTC | #5

    Got it. Will try a workaround in the meantime and try again depending on what you find out.

    Thanks.


    system | 2019-04-22 20:07:17 UTC | #6

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


    tim.smith | 2019-05-22 21:08:13 UTC | #7

    Sorry for the extremely tardy follow up, but this may be unintentional behavior; I don't have a clear answer. If you open a case with PureCloud care, they can investigate further.


    This post was migrated from the old Developer Forum.

    ref: 4842