06-16-2022 11:03 AM
Can someone provide me some sample code in python to create a simple Profile Rule within DNAC via the api. I'm following this and it's not working
https://developer.cisco.com/docs/dna-center/#!create-a-profiling-rule
06-16-2022 01:43 PM - edited 06-16-2022 01:45 PM
Good News, it is right on the link you sent on the right side of the screen. Did you already try and you are getting errors? If so, can you share?
Another tip is to perform a GET of existing content to help you understand the formatting.
import requests
url = "https:///dna/intent/api/v1/endpoint-analytics/profiling-rules"
payload = '''{
"ruleId": null,
"ruleName": null,
"ruleType": "Cisco Default - Static",
"ruleVersion": null,
"rulePriority": null,
"sourcePriority": null,
"isDeleted": null,
"lastModifiedBy": null,
"lastModifiedOn": null,
"pluginId": null,
"clusterId": null,
"rejected": null,
"result": {
"deviceType": [ null ],
"hardwareManufacturer": [ null ],
"hardwareModel": [ null ],
"operatingSystem": [ null ]
},
"conditionGroups": {
"type": "attr",
"condition": {
"attribute": null,
"operator": "equals",
"value": null,
"attributeDictionary": null
},
"operator": "and",
"conditionGroup": [ null ]
},
"usedAttributes": [ null ]
}'''
headers = {
"Content-Type": "application/json",
"Accept": "application/json"
}
response = requests.request('POST', url, headers=headers, data = payload)
print(response.text.encode('utf8'))
06-16-2022 02:50 PM
Hey ModernCyber,
Yeah saw that....however i get a 500 back from DNAC. Below is what i'm running
06-17-2022 05:16 AM
I think see the issue. If you log into our DNAC we're running 2.2.3.4. In the developer toolkit site within DNAC there is a Policy section that has the "create a profiling rule". However if you look at the link i provided first, and then pivot into the 2.2.3 api section, you'll see there's NO POLICY section. I think you have to be running 2.3.3 to have this ability.
06-17-2022 11:16 AM
For this post I doubt if we can do it from Document site.
I suggest to reserve a DNAC sandbox to try or try it from your DNAC.
I tried from my DNAC I got 500 error too. I suspect there is a dependency there.
I tried to do it from GUI (see link below from DNAC user guide) but found out that I don't have any endpoint.
06-17-2022 11:20 AM
Glad it's not just me. and yeah i tried to reserve one of their online labs but said it would take 2 months :).
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