<?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: export_device_configurations API Call Assistance in Network Platform API</title>
    <link>https://community.cisco.com/t5/network-platform-api/export-device-configurations-api-call-assistance/m-p/5233293#M8621</link>
    <description>&lt;P&gt;Which version of Catalyst center are you using?&amp;nbsp;Prior to 2.3.7.X the API and SDK expects deviceId to be a list of device IDs while 2.3.7.X expects a string with a single device ID.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This should start working if you create the api_ object with the attribute version=2.3.5.3 and update your code to this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;r = api_.configuration_archive.export_device_configurations(deviceId=['your-device-id'], password="Password1!")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;If you are running something else than 2.3.5.X the accepted versions you can set are: 2.2.2.3, 2.2.3.3, 2.3.3.0, 2.3.5.3 and 2.3.7.6.&lt;/P&gt;</description>
    <pubDate>Fri, 06 Dec 2024 08:44:09 GMT</pubDate>
    <dc:creator>Torbjørn</dc:creator>
    <dc:date>2024-12-06T08:44:09Z</dc:date>
    <item>
      <title>export_device_configurations API Call Assistance</title>
      <link>https://community.cisco.com/t5/network-platform-api/export-device-configurations-api-call-assistance/m-p/5233065#M8618</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;
&lt;P&gt;I am in need to pull various configurations from Catalyst Center switches via the API. I know Netmiko/Paramiko can be used but the request is to leverage Catalyst Center. I am aware of "&lt;SPAN&gt;devices.get_device_config_by_id('deviceUUID')" or "command_runner.run_read_only_commands_on_devices(commands=cmds, deviceUuids=[device['id']])" however both of these return data masqueraded.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Example:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;snmp-server community xxxxxxxx RO&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I noticed there is another API call called export_device_configurations. Unfortunately I am struggling to figure out how to use it. I am hoping someone within the community can assist with the structure required. I've reviewed the documentation &lt;A href="https://dnacentersdk.readthedocs.io/en/latest/_modules/dnacentersdk/api/v2_3_7_6/configuration_archive.html#ConfigurationArchive" target="_self"&gt;here and&amp;nbsp;&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN&gt;tried setting up the payload with a dictionary with a deviceId and password but still fails:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;r = api_.configuration_archive.export_device_configurations(payload=json.dumps(payload))&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I tried all sort of variations without success and could use any advice that can be shared.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;r = api_.configuration_archive.export_device_configurations(deviceId='xxxxxx', password=p, headers=None, payload=json.dumps(payload), active_validation=True)&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;
&lt;P&gt;-E&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2024 05:24:44 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/export-device-configurations-api-call-assistance/m-p/5233065#M8618</guid>
      <dc:creator>evanm</dc:creator>
      <dc:date>2024-12-07T05:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: export_device_configurations API Call Assistance</title>
      <link>https://community.cisco.com/t5/network-platform-api/export-device-configurations-api-call-assistance/m-p/5233103#M8619</link>
      <description>&lt;P&gt;&lt;SPAN&gt;What does the payload look like, and what error are you getting specifically?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I don't believe you are required to specify a payload for this. Can you try this and post outputs?&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;r = api_.configuration_archive.export_device_configurations(deviceId='your-device-id', password="Password1!")&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 05 Dec 2024 20:41:50 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/export-device-configurations-api-call-assistance/m-p/5233103#M8619</guid>
      <dc:creator>Torbjørn</dc:creator>
      <dc:date>2024-12-05T20:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: export_device_configurations API Call Assistance</title>
      <link>https://community.cisco.com/t5/network-platform-api/export-device-configurations-api-call-assistance/m-p/5233143#M8620</link>
      <description>&lt;P&gt;Appreciate the prompt reply Torbjorn. I tried that earlier but spits out the following:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;gt;&amp;gt;&amp;gt; r = api_.configuration_archive.export_device_configurations(deviceId='xxxxxx-xxxxx-xxxx-xxxx-xxxxxxx', password="Password1!")
Traceback (most recent call last):
  File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;
  File "C:\virtualenv\lib\site-packages\dnacentersdk\api\v2_3_7_6\configuration_archive.py", line 272, in export_device_configurations
    return self.export_device_configurations_v1(
  File "C:\virtualenv\lib\site-packages\dnacentersdk\api\v2_3_7_6\configuration_archive.py", line 147, in export_device_configurations_v1
    json_data = self._session.post(endpoint_full_url, params=_params,
  File "C:\virtualenv\lib\site-packages\dnacentersdk\restsession.py", line 629, in post
    response = self.request('POST', url, erc, 0, params=params,
  File "C:\virtualenv\lib\site-packages\dnacentersdk\restsession.py", line 481, in request
    check_response_code(response, erc)
  File "C:\virtualenv\lib\site-packages\dnacentersdk\utils.py", line 204, in check_response_code
    raise ApiError(response)
dnacentersdk.exceptions.ApiError: [400] Bad Request - BadRequest - JSON parse error: Cannot construct instance of `java.util.ArrayList` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('xxxxxx-xxxxx-xxxx-xxxx-xxxxxxx'); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `java.util.ArrayList` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('xxxxxx-xxxxx-xxxx-xxxx-xxxxxxx')
 at [Source: (PushbackInputStream); line: 1, column: 40] (through reference chain: com.cisco.apicem.config.archive.request.dto.ExportDeviceConfigWrapperDTO["deviceId"]): JSON parse error: Cannot construct instance of `java.util.ArrayList` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('xxxxxx-xxxxx-xxxx-xxxx-xxxxxxx'); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `java.util.ArrayList` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('xxxxxx-xxxxx-xxxx-xxxx-xxxxxxx')
 at [Source: (PushbackInputStream); line: 1, column: 40] (through reference chain: com.cisco.apicem.config.archive.request.dto.ExportDeviceConfigWrapperDTO["deviceId"])&lt;/LI-CODE&gt;&lt;P&gt;I've opened a TAC case but they are being very slow to respond.&lt;BR /&gt;&lt;BR /&gt;Thanks again for trying to help out.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2024 22:27:28 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/export-device-configurations-api-call-assistance/m-p/5233143#M8620</guid>
      <dc:creator>evanm</dc:creator>
      <dc:date>2024-12-05T22:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: export_device_configurations API Call Assistance</title>
      <link>https://community.cisco.com/t5/network-platform-api/export-device-configurations-api-call-assistance/m-p/5233293#M8621</link>
      <description>&lt;P&gt;Which version of Catalyst center are you using?&amp;nbsp;Prior to 2.3.7.X the API and SDK expects deviceId to be a list of device IDs while 2.3.7.X expects a string with a single device ID.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This should start working if you create the api_ object with the attribute version=2.3.5.3 and update your code to this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;r = api_.configuration_archive.export_device_configurations(deviceId=['your-device-id'], password="Password1!")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;If you are running something else than 2.3.5.X the accepted versions you can set are: 2.2.2.3, 2.2.3.3, 2.3.3.0, 2.3.5.3 and 2.3.7.6.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2024 08:44:09 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/export-device-configurations-api-call-assistance/m-p/5233293#M8621</guid>
      <dc:creator>Torbjørn</dc:creator>
      <dc:date>2024-12-06T08:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: export_device_configurations API Call Assistance</title>
      <link>https://community.cisco.com/t5/network-platform-api/export-device-configurations-api-call-assistance/m-p/5233451#M8622</link>
      <description>&lt;P&gt;Thanks Torbjorn. I feel progress is being made but still not fully there. Good suggestion with specifying the version and structuring the deviceId as a list. Not sure why I need to downgrade when we are running Catalyst Center version&amp;nbsp;&lt;SPAN&gt;2.3.7.6-70319 but defining 2.3.5.3 during the initial API call accepts the command.&amp;nbsp; I am now encountering a separate issue however. The file created and being downloaded is corrupted. I see the last&amp;nbsp;Export_Configs-06_Dec_2024_15_54_50_734-DW0.zip but cannot open it. Also seeing a decode error (UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd9 in position 10: invalid continuation byte).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;&amp;gt;&amp;gt;&amp;gt; r = api_.configuration_archive.export_device_configurations(deviceId=['xxxxx-xxxx-xxxx-xxxxxxx'], password="Password1!")
&amp;gt;&amp;gt;&amp;gt; r
{'response': {'taskId': '01939c86-1591-7c62-9ee5-d89768d0e43f', 'url': '/api/v1/task/01939c86-1591-7c62-9ee5-d89768d0e43f'}, 'version': '1.0'}
&amp;gt;&amp;gt;&amp;gt; r = api_.task.get_task_by_id(r.response.taskId)
&amp;gt;&amp;gt;&amp;gt; r
{'response': {'taskId': xxxxxx-xxxx-xxxx-xxxx-d89768d0e43f', 'url': '/api/v1/task/xxxxxx-xxxx-xxxx-xxxx-d89768d0e43f'}, 'version': '1.0'}
&amp;gt;&amp;gt;&amp;gt; r = api_.task.get_task_by_id(r.response.taskId)
&amp;gt;&amp;gt;&amp;gt; r
{'response': {'startTime': 1733497853329, 'progress': 'Device configuration Successfully exported as password protected ZIP.', 'version': 1733497854065, 'data': "Total Device Count: '1', Total Success Count: '1", 'endTime': 1733497854065, 'lastUpdate': 1733497853331, 'additionalStatusURL': '/api/v1/file/xxxxxx-xxxx-xxxx-xxxx-007d0ddf1caa', 'serviceType': 'NCAR', 'isError': False, 'username': 'NCAR88888', 'instanceTenantId': 'xxxxxxxxxxxxx972f', 'id': 'xxxxxx-xxxx-xxxx-xxxx-d89768d0e43f'}, 'version': '1.0'}
&amp;gt;&amp;gt;&amp;gt;cmd_output = api_.file.download_a_file_by_fileid('xxxxxx-xxxx-xxxx-xxxx-007d0ddf1caa', save_file=True, dirpath="logs")
&amp;gt;&amp;gt;&amp;gt; cmd_output.json()
Traceback (most recent call last):
  File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;
  File "C:\virtualenv\lib\site-packages\urllib3\response.py", line 384, in json
    data = self.data.decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd9 in position 10: invalid continuation byte&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Any idea what I am doing wrong?&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2024 16:18:42 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/export-device-configurations-api-call-assistance/m-p/5233451#M8622</guid>
      <dc:creator>evanm</dc:creator>
      <dc:date>2024-12-06T16:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: export_device_configurations API Call Assistance</title>
      <link>https://community.cisco.com/t5/network-platform-api/export-device-configurations-api-call-assistance/m-p/5233514#M8623</link>
      <description>&lt;P&gt;That's odd. I just tested against a Cat-C running 2.3.7.6 in my lab and found that the API docs(and hence the SDK) is wrong in that deviceId should be a string in 2.3.7.X. There also seems to be changes to the API for file download between 2.3.5 and 2.3.7, so my guess would be that cmd_output.json() fails due to version incompatibility(data/objects don't adhere to expected format for 2.3.5). I don't think it is a good use of time to troubleshoot this further until the SDK error has been mended.&lt;/P&gt;&lt;P&gt;I have created &lt;A href="https://github.com/cisco-en-programmability/dnacentersdk/issues/182" target="_self"&gt;an Issue for this on github&lt;/A&gt; and will (probably) create a fix at some point in the coming days. You should bring up the API documentation &amp;amp; SDK error with TAC.&lt;/P&gt;&lt;P&gt;EDIT: Are you able to pass deviceId as a list without setting version if you set&amp;nbsp;&lt;SPAN&gt;active_validation to False? If so that could be a workaround for the time being.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2024 21:24:43 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/export-device-configurations-api-call-assistance/m-p/5233514#M8623</guid>
      <dc:creator>Torbjørn</dc:creator>
      <dc:date>2024-12-06T21:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: export_device_configurations API Call Assistance</title>
      <link>https://community.cisco.com/t5/network-platform-api/export-device-configurations-api-call-assistance/m-p/5233551#M8624</link>
      <description>&lt;P&gt;Thank you so much Torbjorn! FYI, I was able to get SDK '2.3.7.6' to accept the "configuration_archive.export_device_configurations" call with active_validation set to false. I still run into the issue however of exporting the configuration file.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;UnicodeDecodeError: 'utf-8' codec can't decode byte 0x86 in position 12: invalid start byte&lt;/LI-CODE&gt;&lt;P&gt;TAC confirmed they can reproduce it and will work internally on getting a resolution for the&amp;nbsp;&lt;SPAN&gt;API documentation &amp;amp; SDK error.&amp;nbsp;I've send you a little e-transfer for coffee or beer. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;Regards.&lt;BR /&gt;&lt;BR /&gt;-E&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2024 21:54:02 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/export-device-configurations-api-call-assistance/m-p/5233551#M8624</guid>
      <dc:creator>evanm</dc:creator>
      <dc:date>2024-12-06T21:54:02Z</dc:date>
    </item>
  </channel>
</rss>

