<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: DNAC API - Command Runner - Failure to obtain taskId in Network Platform API</title>
    <link>https://community.cisco.com/t5/network-platform-api/dnac-api-command-runner-failure-to-obtain-taskid-solved/m-p/4472447#M9012</link>
    <description>&lt;P&gt;I think I found the answer to my question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;print(commandrunner['response'])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the message was as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{'errorCode': 'Bad request', 'message': 'Invalid input request', 'detail': 'Maximum of 5 commands allowed per request'}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I guess it is the limitation of the API to a maximum of 5 commands allowed per request.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will test this further by dividing my requests into chunks of 5 commands at a time.&lt;/P&gt;</description>
    <pubDate>Thu, 23 Sep 2021 21:54:24 GMT</pubDate>
    <dc:creator>wieniec17</dc:creator>
    <dc:date>2021-09-23T21:54:24Z</dc:date>
    <item>
      <title>DNAC API - Command Runner - Failure to obtain taskId [solved]</title>
      <link>https://community.cisco.com/t5/network-platform-api/dnac-api-command-runner-failure-to-obtain-taskid-solved/m-p/4471674#M9009</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I started playing with the DNAC API and the command runner but I ran into a problem where I want to run ten or more show commands inside the payload. Up to four show commands works fine, but more than that comes back with failure to obtain taskId. I am using Python for the scripting language and the DNAC is the online sandbox provided by Cisco.&lt;/P&gt;&lt;P&gt;I tried scripting this job based on the documentation located here:&amp;nbsp;&lt;A href="https://developer.cisco.com/docs/dna-center/#!cisco-dna-center-platform-overview" target="_blank" rel="noopener"&gt;https://developer.cisco.com/docs/dna-center/#!cisco-dna-center-platform-overview&lt;/A&gt;. I also tried other sources and ready-made scripts which I found online and problem is the same.&lt;/P&gt;&lt;P&gt;Is this the limitation of the freely available DNAC sandbox, the DNAC API bug or what is it?&lt;/P&gt;&lt;P&gt;Any guidance in this matter will be greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 09:10:13 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/dnac-api-command-runner-failure-to-obtain-taskid-solved/m-p/4471674#M9009</guid>
      <dc:creator>wieniec17</dc:creator>
      <dc:date>2021-09-28T09:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: DNAC API - Command Runner - Failure to obtain taskId</title>
      <link>https://community.cisco.com/t5/network-platform-api/dnac-api-command-runner-failure-to-obtain-taskid-solved/m-p/4471693#M9010</link>
      <description>&lt;P&gt;When running tests using the API and you experience issues:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Please provide the URL &amp;amp; Method Used&lt;/LI&gt;
&lt;LI&gt;Please provide the Body of the Request that is failing&lt;/LI&gt;
&lt;LI&gt;Please provide the method of using the API &amp;nbsp;(ie. Cisco DNA Center itself, Postman, etc...)&lt;/LI&gt;
&lt;LI&gt;Cisco DNA Center version being used&lt;/LI&gt;
&lt;LI&gt;Device Type, Model, and software version for this request&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;This will help the viewing audience to assess the issue and provide feedback.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Sep 2021 22:47:07 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/dnac-api-command-runner-failure-to-obtain-taskid-solved/m-p/4471693#M9010</guid>
      <dc:creator>Tomas de Leon</dc:creator>
      <dc:date>2021-09-22T22:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: DNAC API - Command Runner - Failure to obtain taskId</title>
      <link>https://community.cisco.com/t5/network-platform-api/dnac-api-command-runner-failure-to-obtain-taskid-solved/m-p/4472444#M9011</link>
      <description>&lt;P&gt;Hi Tomas,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here goes:&lt;/P&gt;&lt;P&gt;I am using Python for this and the DNAC is the&amp;nbsp;"&lt;A href="https://sandboxdnac.cisco.com" target="_blank"&gt;https://sandboxdnac.cisco.com&lt;/A&gt;" (&lt;SPAN&gt;Version&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;2.2.2.3).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;List of devices and their versions is in the attached image, although the WLC seems to be ignored by the command runner.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Script is below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;....Start of script:.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;import requests&lt;BR /&gt;from requests.auth import HTTPBasicAuth&lt;BR /&gt;import json&lt;BR /&gt;import csv&lt;BR /&gt;import pandas as pd&lt;BR /&gt;import getpass&lt;BR /&gt;import time&lt;BR /&gt;import urllib3&lt;BR /&gt;urllib3.disable_warnings()&lt;BR /&gt;&lt;BR /&gt;'''&lt;BR /&gt;DNA Details&lt;BR /&gt;'''&lt;BR /&gt;print("Enter DNAC Credentials to login:")&lt;BR /&gt;DNAC_URL = "https://sandboxdnac.cisco.com"&lt;BR /&gt;DNAC_AUTH_URL = '/dna/system/api/v1/auth/token'&lt;BR /&gt;DNAC_PORT = 443&lt;BR /&gt;DNAC_USER = "devnetuser"&lt;BR /&gt;DNAC_PASSWORD = "Cisco123!"&lt;BR /&gt;&lt;BR /&gt;'''&lt;BR /&gt;Login&lt;BR /&gt;'''&lt;BR /&gt;&lt;BR /&gt;login = requests.post(DNAC_URL + DNAC_AUTH_URL, auth=HTTPBasicAuth(DNAC_USER, DNAC_PASSWORD), verify=False)&lt;BR /&gt;token = login.json()['Token']&lt;BR /&gt;headers = {'X-Auth-Token': token, 'Content-Type': 'application/json'}&lt;BR /&gt;&lt;BR /&gt;'''&lt;BR /&gt;URLs&lt;BR /&gt;'''&lt;BR /&gt;DEVICES_URL = '/dna/intent/api/v1/network-device'&lt;BR /&gt;COMMAND_RUNNER_SEND_URL = '/dna/intent/api/v1/network-device-poller/cli/read-request'&lt;BR /&gt;TASK_BY_ID_URL = '/dna/intent/api/v1/task/{task_id}'&lt;BR /&gt;FILE_GET_BY_ID = '/dna/intent/api/v1/file/{file_id}'&lt;BR /&gt;&lt;BR /&gt;'''&lt;BR /&gt;GETs&lt;BR /&gt;'''&lt;BR /&gt;get_devices = requests.get(DNAC_URL + DEVICES_URL, headers = headers, verify=False)&lt;BR /&gt;get_devices_json = get_devices.json()['response']&lt;BR /&gt;&lt;BR /&gt;devices = []&lt;BR /&gt;for device in get_devices.json()['response']:&lt;BR /&gt;    devices.append(device['id'])&lt;BR /&gt;&lt;BR /&gt;payload = {&lt;BR /&gt;  "commands": [&lt;BR /&gt;    "show running-config",&lt;BR /&gt;    "show ip arp",&lt;BR /&gt;    "show mac address-table",&lt;BR /&gt;    "show ip route",&lt;BR /&gt;    "show interface",&lt;BR /&gt;    "show ip interface",&lt;BR /&gt;    "show inventory",&lt;BR /&gt;    "show version",&lt;BR /&gt;    "show cdp neighbors detail",&lt;BR /&gt;    "show cdp neighbors",&lt;BR /&gt;    "show lldp neighbors",&lt;BR /&gt;    "show lldp neighbors detail"&lt;BR /&gt;  ],&lt;BR /&gt;  "deviceUuids": devices,&lt;BR /&gt;  "timeout": 0&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;commandrunner = requests.post(DNAC_URL + COMMAND_RUNNER_SEND_URL, data=json.dumps(payload), headers=headers, verify=False).json()&lt;BR /&gt;&lt;BR /&gt;time.sleep(10)&lt;BR /&gt;&lt;BR /&gt;task_id = commandrunner['response']['taskId']&lt;BR /&gt;&lt;BR /&gt;get_file_id = requests.get(DNAC_URL + TASK_BY_ID_URL.format(task_id=task_id), headers=headers, verify=False)&lt;BR /&gt;progress_json = json.loads(get_file_id.json()['response']['progress'])&lt;BR /&gt;file_id = progress_json['fileId']&lt;BR /&gt;get_file = requests.get(DNAC_URL + FILE_GET_BY_ID.format(file_id=file_id), headers=headers, verify=False)&lt;BR /&gt;file_json = get_file.json()&lt;BR /&gt;&lt;BR /&gt;for item in get_devices_json:&lt;BR /&gt;    deviceid = item['id']&lt;BR /&gt;    devicehostname = item['hostname']&lt;BR /&gt;&lt;BR /&gt;for item in file_json:&lt;BR /&gt;    device = item['deviceUuid']&lt;BR /&gt;    commandresponse = item['commandResponses']&lt;BR /&gt;    successfullcommands = commandresponse['SUCCESS']&lt;BR /&gt;    show_running_config = successfullcommands['show running-config']&lt;BR /&gt;    show_ip_arp = successfullcommands['show ip arp']&lt;BR /&gt;    show_mac_address_table = successfullcommands['show mac address-table']&lt;BR /&gt;    show_ip_route_vrf_xD = successfullcommands['show ip route']&lt;BR /&gt;    show_interface = successfullcommands['show interface']&lt;BR /&gt;    show_ip_interface = successfullcommands['show ip interface']&lt;BR /&gt;    show_inventory = successfullcommands['show inventory']&lt;BR /&gt;    show_version = successfullcommands['show version']&lt;BR /&gt;    show_cdp_neighbors_detail = successfullcommands['show cdp neighbors detail']&lt;BR /&gt;    show_cdp_neighbors = successfullcommands['show cdp neighbors']&lt;BR /&gt;    show_lldp_neighbors = successfullcommands['show lldp neighbors']&lt;BR /&gt;    show_lldp_neighbors_detail = successfullcommands['show lldp neighbors detail']&lt;BR /&gt;    with open(device + "show running-config.txt", 'w') as f:&lt;BR /&gt;        f.write(show_running_config)&lt;BR /&gt;    with open(device + "show ip arp.txt", 'w') as f:&lt;BR /&gt;        f.write(show_ip_arp)&lt;BR /&gt;    with open(device + "show mac address-table.txt", 'w') as f:&lt;BR /&gt;        f.write(show_mac_address_table)&lt;BR /&gt;    with open(device + "show ip route xD.txt", 'w') as f:&lt;BR /&gt;        f.write(show_ip_route_vrf_xD)&lt;BR /&gt;    with open(device + "show interface.txt", 'w') as f:&lt;BR /&gt;        f.write(show_interface)&lt;BR /&gt;   with open(device + "show ip interface.txt", 'w') as f:&lt;BR /&gt;        f.write(show_ip_interface)&lt;BR /&gt;   with open(device + "show inventory.txt", 'w') as f:&lt;BR /&gt;        f.write(show_inventory)&lt;BR /&gt;    with open(device + "show version.txt", 'w') as f:&lt;BR /&gt;        f.write(show_version)&lt;BR /&gt;    with open(device + "show cdp neighbors detail.txt", 'w') as f:&lt;BR /&gt;        f.write(show_cdp_neighbors_detail)&lt;BR /&gt;    with open(device + "show cdp neighbors.txt", 'w') as f:&lt;BR /&gt;        f.write(show_cdp_neighbors)&lt;BR /&gt;    with open(device + "show lldp neighbors.txt", 'w') as f:&lt;BR /&gt;        f.write(show_lldp_neighbors)&lt;BR /&gt;    with open(device + "show lldp neighbors detail.txt", 'w') as f:&lt;BR /&gt;        f.write(show_lldp_neighbors_detail)&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;When running this script, the message I am getting is :&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "C:\temp\DNA\test4.py", line 70, in &amp;lt;module&amp;gt;&lt;BR /&gt;task_id = commandrunner['response']['taskId']&lt;BR /&gt;KeyError: 'response'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the same message each time I run the script with more than four show commands inside the payload. If cut the payload down to only four show commands, everything works fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Sep 2021 21:43:08 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/dnac-api-command-runner-failure-to-obtain-taskid-solved/m-p/4472444#M9011</guid>
      <dc:creator>wieniec17</dc:creator>
      <dc:date>2021-09-23T21:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: DNAC API - Command Runner - Failure to obtain taskId</title>
      <link>https://community.cisco.com/t5/network-platform-api/dnac-api-command-runner-failure-to-obtain-taskid-solved/m-p/4472447#M9012</link>
      <description>&lt;P&gt;I think I found the answer to my question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;print(commandrunner['response'])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the message was as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{'errorCode': 'Bad request', 'message': 'Invalid input request', 'detail': 'Maximum of 5 commands allowed per request'}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I guess it is the limitation of the API to a maximum of 5 commands allowed per request.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will test this further by dividing my requests into chunks of 5 commands at a time.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Sep 2021 21:54:24 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/dnac-api-command-runner-failure-to-obtain-taskid-solved/m-p/4472447#M9012</guid>
      <dc:creator>wieniec17</dc:creator>
      <dc:date>2021-09-23T21:54:24Z</dc:date>
    </item>
  </channel>
</rss>

