Cognos Analytics

 View Only

Multipage Reports via Reporting API

  • 1.  Multipage Reports via Reporting API

    Posted Tue July 27, 2021 06:01 PM
    Hi there,

    I'm new to Cognos and the reporting API. I've been able to pull small CSV reports successfully using the API in Python, but am having trouble successfully requesting multiple pages and getting multi-page results to return in CSV format.  I'm posting a few code snippets below that I'm using after successfully authenticating the session. I'm happy to post that bit as well if it's helpful context. Note that the request headers contain the XSRF token, the data contains the login information, all as specified here. I'm looking here for the documentation on how to pull the next report page.

    I'm in the care manager domain, base_url is constructed as base_url = f"https://{domain}/wcmreportingapi/{tenant_id}/{tenant_instance_id}".

    Thanks in advance for your help!


    1) Pull the next page of the report

    # Make paged report request, this works
    r = session.get(
        base_url + f"/disp/rds/pagedReportData/report/{​report_id}​?v=3&async=",
        headers=headers,
        data=data
    )

     

    # Add the next command to the URL returned in the Header
    url_pieces = r.headers["urlfinal"].split("?")
    next_url = url_pieces[0] + "/next?" + url_pieces[1]
    # next_url ends up being something like:
    # 'https://<domain>/bi/v1/disp/rds/sessionOutput/conversationID/<conversation_id>/next?v=3'

     

    # Returns a 403 Forbidden code with the following in the content:
    # The currently provided credentials are invalid. Please provide the logon credentials.

    t = session.get(
        next_url,
        headers=headers,
        data=data
    )

    2) Pull the paged report as a CSV

     

    # This successfully gets a CSV report, i.e. at the outputFormat endpoint with CSV specified after report ID
    r = session.get(
        base_url + f"/disp/rds/outputFormat/report/{​report_id}​/CSV?v=3&async=",
        headers=headers,
        data=data
    )

     

    # This returns HTML, i.e. using the pagedReportData endpoint but attempting to specify CSV

    r = session.get(
        base_url + f"/disp/rds/pagedReportData/report/{​report_id}​/CSV?v=3&async=",
        headers=headers,
        data=data
    )

     

    # This gets a 404 error / not found, i.e. trying to combined the endpoints… didn't expect this to work but gotta try something
    r = session.get(
        base_url + f"/disp/rds/pagedReportData/outputFormat/report/{​report_id}​/CSV?v=3&async=",
        headers=headers,
        data=data
    )



    ------------------------------
    Claire Herdeman
    ------------------------------

    #CognosAnalyticswithWatson