pull csv report via rest api


how to generate csv report and download using rest api


Best answer by Stuart Weenig 11 May 2023, 15:37

View original

6 replies

Userlevel 7
Badge +17

You can use GET /report/links/{reportid} to get the list of links to the data. (warning, this endpoint is technically unsupported because LM decided it should be undocumented)

You’re supposed to be able to POST to /report/reports/{reportid}/executions to get it to generate the report immediately. The response should have the result url in it. However, in my testing the report url was always null because the report was not done generating by the time the API sent the response. Also, with this request, you have to pass in an email address that you want to send the report to. Once the task is finished, even if you get a null value in the API response, you will get the email with the link to the report.

So you should be able to

  1. POST to /report/reports/{reportid}/executions with a bogus email (or your own) to start generating the report.
  2. You probably want to wait a few seconds (maybe 30, maybe longer depending on the size of the report).
  3. Then you should be able to GET at /report/links/{reportid} and get the last item in the list `$.items[-1:].reportUrl`. Then it would be a get at that URL. Be careful, it looks like there are extra spaces around the reportUrl, so use a .trim() method to clean it up before trying to fetch the CSV data itself.

Before you start, you could do the GET on /report/links/{reportid} first to get the id of the last report data. That would let you do repeated GETs at /report/links/{reportid} after doing your post and check if the new data is present by looking for a new ID after the known ID. That would let you wait a minimal amount of time before fetching the data again.


Thank You

Stuart Weenig for swift reply.

I am getting 404 error please refer the attachment.


Userlevel 7
Badge +17

Looks like you’re not using Postman with variables. Your content-type is bad and you’re missing some stuff. Does postman work for any requests? Make sure your postman is working right.

Also, it looks like you have redacted some information, but you didn’t redact your API key.


Sorry its company’s job so hide the url

Stuart, how can we get report_id code to get reports

I am using Postman for testing purpose is there any other tool to test

Thank You Stuart for time and Support

Userlevel 7
Badge +17

Postman is the right way to test it out. Did you follow the instructions in the link? Do that first and test that you have it working by doing a GET on /report/reports. 

It’s fine that you redacted some information, but you didn’t redact your API key, which is the actual password to get into your API. You should be using the pre-request script in postman, all of which is explained in the postman setup instructions linked above.

This “used” to work by using this:

Get a URL for an existing Report execution task


URI: /report/reports/REPORT_ID/tasks/TASK_ID

Where REPORT_ID is the id of the report, and TASK_ID is the id of the task you’re wanting to get a report URL for (returned when you run the report).


As documented here:


It stopped working in our portal early April (right after a portal upgrade). I’ve had an open case ever since.