how to generate csv report and download using rest api
Best answer by Stuart Weenig
View originalhow to generate csv report and download using rest api
Best answer by Stuart Weenig
View originalYou 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
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.
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
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:
HTTP Method:GET
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:
https://www.logicmonitor.com/support/rest-api-developers-guide/v1/reports/run-a-report
It stopped working in our portal early April (right after a portal upgrade). I’ve had an open case ever since.
Already have an account? Login
No account yet? Create an account
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.