1 Rookie
•
39 Posts
0
759
REST API - Reading Report
Trying to run a report and download info via REST API and requests library in Python
Have managed to get the report to run but cannot pass the parameter for the ReportID using /api/ReportService/ReportDefs(Id)/ReportResults/Result as I cannot work out how to pass the Id parameter.
Can anyone give me a hint? As you can tell I am a bodger rather than a programmer.
jaimie.harris
1 Rookie
1 Rookie
•
39 Posts
0
October 13th, 2020 02:00
okay, so with a bit of help from a colleague I got this working. If anyone wants the answer here is code that should work
+++++++++++++++++++++++ Code sample +++++++++++++++++++++++++++++++++++++++++++++++
import json
import requests
if __name__ == '__main__':
headers = {'content-type': 'application/json'}
user_details = {'UserName': user,'Password': password,'SessionType': 'API'}
session_info = requests.post('https:// /api/SessionService/Sessions',verify=False,data=json.dumps(user_details),headers=headers)
headers['X-Auth-Token'] = session_info.headers['X-Auth-Token']
report_details = {'ReportDefId': 'id','FilterGroupId': '0'}
hba_reports_response = requests.post('https:// /api/ReportService/Actions/ReportService.RunReport',verify=False,data=json.dumps(report_details),headers=headers)
hba_report_data = requests.get('https:// /api/ReportService/ReportDefs(id)/ReportResults/ResultRows',headers=headers, verify=False)
print(hba_report_data.text)
+++++++++++++++++++++++++++++++++++++ End of code sample +++++++++++++++++++++++++++++++
DELL-Charles R
Moderator
Moderator
•
3.4K Posts
0
October 12th, 2020 12:00
Hello jaimie.harris,
I think this may be what you are looking for:
OpenManage Enterprise Version 3.4 and OpenManage Enterprise - Modular Edition Version 1.20.00 RESTful API Guide
Report Service starting page 568
/api/ReportService/ReportDefs(Id)/ReportResults Page 572
https://dell.to/36ZzhxS
I'm not to familiar with the scripting but I'll do what I can and maybe other forum members may chime in also.
jaimie.harris
1 Rookie
1 Rookie
•
39 Posts
0
October 12th, 2020 23:00
Charles
Thanks but that was not what I was asking, my apologies for not being clearer.
The issue is how do I pass the ID which is in parentheses in the middle of the URI. This may well be more of a python thing rather than a Dell thing but I figured someone on here may have come up against it.