04-04-2023 01:02 AM
I have been trying for hours to use the reports API to create a report in DNAC. I have followed the guidelines to a T, but I get error 500 no matter what. I even used the "Inspect" tool with Chrome and created a report using the GUI, but the format still gave me an error 500. Here is my code:
Solved! Go to Solution.
04-05-2023 05:57 PM
RESOLVED
Looks like the API document is not 100% accurate. When using Python Requests, you must turn the payload dict into JSON:
04-05-2023 05:57 PM
RESOLVED
Looks like the API document is not 100% accurate. When using Python Requests, you must turn the payload dict into JSON:
04-06-2023 09:08 AM
Hi Todd (I guess)
happy to see you found the solution, and thanks for sharing it here. Could you clarifiy which API document you consider to be not accurate please, so we can review and update it?
regards
Herbert
04-08-2023 05:03 PM
04-28-2023 04:55 AM
Hi Todd,
ok it wasn't clear to me at first which doc you meant, but I see now it's the "python-request" template at https://developer.cisco.com/docs/dna-center/#!create-or-schedule-a-report
(and by extention, probably all the templates for all the POST API calls, not only this one).
I'll see if I can find the right person to fix this. Thanks for reporting it!
Herbert
06-16-2023 07:52 AM - edited 06-16-2023 01:40 PM
Todd,
on second thought, I believe the documentation is actually correct. The payload object is a string (containing JSON), not a dict.
I suspect you may have accidentally left out the quotes ? I.e. if you write it as:
payload = {
"schedule": {},
"view": { "format": {} }
}
then payload is a dict and you need to use json.dumps(payload) to turn it into a json string.
But in the documentation, payload is a multi-line string:
payload = '''{
"schedule": {},
"view": { "format": {} }
}'''
So while this looks very similar to the dict, it is actually a valid JSON string.
Herbert
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide