Downloading large reports via API issue

I’m getting report output using the API call ‘/api/3/reports/{id}/history/{instance}/output’ to download a generated report and save the contents to a file locally on a server, the problem I’m seeing is with larger files they fail to download and after a good bit of test I can only surmise that it’s due to the returned data from the API call being loaded into memory before being written to the file locally which is exhausting the memory allocation and in turn causes the download to fail. There are numerous scripts running for different instances so server resrouces can be consumed quick enough.

I saw that with the response from the above API call there is a URL for the direct download of the generated report that I could write in chunks to a local file but if I try to use it the script gets redirected to the Nexpose login page.

So two questions:

• Is there a way to compress/deflate a report before downloading it?
• If I use the direct download URL is there a way around the login page from a service/script?

This is all done via a python 3.x script.

Any help is greatly appreciated.

Hi Adam,

Unfortunately, I’m unaware of a way to compress the report before downloading it.

For the direct download URL, you could perhaps get around the login page by adding the proper auth token headers to your request (although I haven’t tested it). The InsightVM InsightConnect plugin should have some examples of that (specifically here):

Hope that helps!

@adam_tallon FYI, just updated the link to reference the specific function that adds the session headers.