Classic file types are no longer available for use as of January 2021. You can transition your classic files or download a PDF. Learn More

Issue with Applying Filters on Workiva API Reports

Answered
0

Comments

5 comments

  • Official comment
    Colleen Hardie

    Hi, Pranchal.

    The endpoint to retrieve a CSV report doesn't allow filtering, it will simply retrieve a CSV of a saved report as-is. The endpoint discussed in that documentation that does allow filtering is the endpoint to retrieve records (see the documentation for what's allowed).

    Please let us know if you continue to encounter issues.

    Best,

    Colleen

  • Pranchal Gupta

    Thank you for your response Colleen Hardie.

    I have two questions:

    1. I understand that direct filters cannot be applied to the API. Is there an alternative method to implement filters on top of it?

    2. What is the recommended approach to apply pagination logic to these report APIs? Specifically, could you outline the steps involved?
    Thank you.

    Regards,
    Pranchal

    0
  • Mike Thiesen

    Hello Pranchal,
    There isn't a way to create CSV filters through the API. However, it may be possible to add filters through the UI used to create the report.

    There also isn't any way to paginate those reports. If you are having trouble downloading those reports, try using the POST /graph/reports/{reportId}/export endpoint described here:
    https://developers.workiva.com/workiva-platform/reference/platform-graphreportexport

    That export endpoint has no size limits so you can download large CSVs and then filter them yourself. The export endpoint is asynchronous, so it does involve a couple of extra steps. You will need to inspect the "Location" header of the response which includes the url to an operation for the export. You will then need to repeatedly check that operations endpoint to monitor the export progress. Once the operations endpoint returns a status of "completed" your csv can be downloaded from the URL found in the resourceUrl field. See the export endpoint descriptions for details. 


    0
  • Pranchal Gupta

    Hi Mike Thiesen

    Thank you so much for your response.
    It helps a lot, but we are not getting any headers as location, so could you please help us with that?
    These are the inputs:
    URL: /graph/reports/{reportId}/export 
    Headers : Authorization and Content-Type

    Body: {  

    "format": "csv"

    }
    Output:
    {
        "id": "",
        "status": "completed",
        "resourceUrl": "__",
        "created": {
            "dateTime": "2024-07-23T13:13:58Z"
        },
        "updated": {
            "dateTime": "2024-07-23T13:14:03Z"
        },
        "originalRequest": "",
        "ADFWebActivityResponseHeaders": {
            "Connection": "keep-alive",
            "x-amzn-RequestId": "  ",
            "CF-RAY": "  ",
            "x-xss-protection": "  ",
            "access-control-allow-origin": " ",
            "CF-Cache-Status": " ",
            "strict-transport-security": " ",
            "x-frame-options": " ",
            "x-amzn-Remapped-Connection": " ",
            "x-request-id": "",
            "x-amz-apigw-id": "",
            "vary": " ",
            "x-amzn-Remapped-Server": " ",
            "x-content-type-options": " ",
            "retry-after": " ",
            "x-amzn-Remapped-Date": "Tue, 23 Jul 2024 13:14:03 GMT",
            "X-Cache": " ",
            "X-Amz-Cf-Pop": " ",
            "X-Amz-Cf-Id": " ",
            "Cache-Control": " ",
            "Date": "Tue, 23 Jul 2024 13:14:03 GMT",
            "Via": "",
            "Content-Length": " ",
            "Content-Type": "application/json"
        }

    0
  • Patrick O'Connor

    Hi Pranchal Gupta

    The location header comes back in the response from `/graph/reports/{reportId}/export `. You can see that in the documentation here:
    https://developers.workiva.com/workiva-platform/reference/platform-graphreportexport#returns

    It looks like you're already polling that operation location correctly though based off the Output you're getting. Here's the documentation for GetOperationByID:
    https://developers.workiva.com/workiva-platform/reference/platform-operations

    You should be able to download the file by issuing a GET request to the `resourceUrl` field of the Operation. You will also need to include your Authorization header. Here's an example curl command. Hopefully you can translate this to whatever client you're using:

    curl '<resourceUrl>' -H "Authorization: Bearer <authorization>" --output report.pdf

    This will create a file called report.pdf but you're welcome to change that to whatever makes sense for you.

    Hope that helps!

    0

Please sign in to leave a comment.