Practice – Cisco DNAC Python

Logged in as

Fill in the missing parts of this DNAC Python function that creates a site.

Drag the correct code snippets from the options panel into the placeholders in the code window.

import requests import json base_url = 'https://your_dnac_ip/api/v1' auth_token = '{{AUTH_TOKEN}}' def create_site(site_name, parent_site_id=None): headers = { 'X-auth-token': auth_token, 'Content-Type': 'application/json' } data = { 'siteNameHierarchy': [site_name], 'parentName': parent_site_id } response = requests.post(f'{base_url}/dna/intent/api/v1/site', headers=headers, data=json.dumps(data)) if response.status_code == {{STATUS_CODE}}: print("{{SUCCESS_MSG}}") else: print("Failed to create site. Status code:", response.status_code) create_site('{{SITE_NAME}}', parent_site_id='parent_site_id')

Drag a snippet from the right into each blank box in the code.

Available snippets

auth_token
201
Site created successfully.
New Site
200
Request completed.