<?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: Cisco DNAC  - REST API Call to retrieve token. in Network Platform API</title>
    <link>https://community.cisco.com/t5/network-platform-api/cisco-dnac-rest-api-call-to-retrieve-token/m-p/5148129#M8691</link>
    <description>&lt;P&gt;Also see&amp;nbsp;&lt;A href="https://community.cisco.com/t5/devnet-sandbox/unable-to-do-rest-api-s-to-catalyst-centers/m-p/5147187/highlight/true#M10221" target="_blank"&gt;https://community.cisco.com/t5/devnet-sandbox/unable-to-do-rest-api-s-to-catalyst-centers/m-p/5147187/highlight/true#M10221&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 22 Jul 2024 10:10:33 GMT</pubDate>
    <dc:creator>Marcel Zehnder</dc:creator>
    <dc:date>2024-07-22T10:10:33Z</dc:date>
    <item>
      <title>Cisco DNAC  - REST API Call to retrieve token.</title>
      <link>https://community.cisco.com/t5/network-platform-api/cisco-dnac-rest-api-call-to-retrieve-token/m-p/5147928#M8689</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;For some reason, it appears that I am receiving the response for a token in request in html format indicated by the following error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;nbsp; File "/&lt;/I&gt;&lt;I&gt;usr&lt;/I&gt;&lt;I&gt;/lib64/python3.9/&lt;/I&gt;&lt;I&gt;json&lt;/I&gt;&lt;I&gt;/decoder.py", line 355, in &lt;/I&gt;&lt;I&gt;raw_decode&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise &lt;/I&gt;&lt;I&gt;JSONDecodeError&lt;/I&gt;&lt;I&gt;("Expecting value", s, &lt;/I&gt;&lt;I&gt;err.value&lt;/I&gt;&lt;I&gt;) from None&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;json.decoder.JSONDecodeError&lt;/I&gt;&lt;I&gt;: Expecting value: line 1 column 1 (char 0)&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;I&gt;Below you will find an excerpt of the code:&lt;/I&gt;&lt;/P&gt;&lt;P&gt;#!/usr/bin/python&lt;/P&gt;&lt;P&gt;import requests&lt;/P&gt;&lt;P&gt;import json&lt;/P&gt;&lt;P&gt;import urllib3&lt;/P&gt;&lt;P&gt;from requests.auth import HTTPBasicAuth&lt;/P&gt;&lt;P&gt;urllib3.disable_warnings()&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;my_dna_ctr="sandboxdnac2.cisco.com"&lt;/P&gt;&lt;P&gt;my_user="devnetuser"&lt;/P&gt;&lt;P&gt;my_password="Cisco123!"&lt;/P&gt;&lt;P&gt;tkn_headers={"Content-Type": "application/json"}&lt;/P&gt;&lt;P&gt;my_tkn_uri="https://"+my_dna_ctr+"/dna/system/api/vi/auth/token"&lt;/P&gt;&lt;P&gt;my_tkn_req=requests.post(my_tkn_uri, auth=HTTPBasicAuth(my_user, my_password),headers=tkn_headers,verify=False)&lt;/P&gt;&lt;P&gt;my_access_token=my_tkn_req.json()["Token"]&lt;/P&gt;&lt;P&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate any help.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2024 03:49:54 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/cisco-dnac-rest-api-call-to-retrieve-token/m-p/5147928#M8689</guid>
      <dc:creator>Netmart</dc:creator>
      <dc:date>2024-07-22T03:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: Cisco DNAC  - REST API Call to retrieve token.</title>
      <link>https://community.cisco.com/t5/network-platform-api/cisco-dnac-rest-api-call-to-retrieve-token/m-p/5148062#M8690</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/244740"&gt;@Netmart&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First - seems like your URL is wrong. It should be&amp;nbsp;&lt;SPAN&gt;/dna/system/api/v1/auth/token &amp;lt;- there is "v1" instead of "vi".&lt;BR /&gt;&lt;BR /&gt;I tested your script and unfortunately there is a problem with authentication endpoint on dnac. I got response:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
    "error": "Basic Authorization is not allowed"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Seems like sandboxdnac2 has Basic auth disabled, because i tried to authenticate using GUI and Dev Toolkit - i got the same result.&lt;BR /&gt;&lt;BR /&gt;BUT - you can use&amp;nbsp;&lt;A href="https://sandboxdnac.cisco.com/" target="_blank" rel="noopener"&gt;https://sandboxdnac.cisco.com/&lt;/A&gt;&amp;nbsp;without "2" and this will return you token with no issues so maybe this is the option?&lt;BR /&gt;&lt;BR /&gt;The code with typo fixed:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#!/usr/bin/python
import requests
import json
import urllib3
from requests.auth import HTTPBasicAuth
urllib3.disable_warnings()


my_dna_ctr="sandboxdnac.cisco.com"
my_user="devnetuser"
my_password="Cisco123!"
tkn_headers={"Content-Type": "application/json"}

my_tkn_uri="https://"+my_dna_ctr+"/dna/system/api/v1/auth/token"
my_tkn_req=requests.post(my_tkn_uri, auth=HTTPBasicAuth(my_user, my_password),headers=tkn_headers,verify=False)

my_access_token=my_tkn_req.json()​["Token"]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2024 08:05:06 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/cisco-dnac-rest-api-call-to-retrieve-token/m-p/5148062#M8690</guid>
      <dc:creator>mfr-6</dc:creator>
      <dc:date>2024-07-22T08:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Cisco DNAC  - REST API Call to retrieve token.</title>
      <link>https://community.cisco.com/t5/network-platform-api/cisco-dnac-rest-api-call-to-retrieve-token/m-p/5148129#M8691</link>
      <description>&lt;P&gt;Also see&amp;nbsp;&lt;A href="https://community.cisco.com/t5/devnet-sandbox/unable-to-do-rest-api-s-to-catalyst-centers/m-p/5147187/highlight/true#M10221" target="_blank"&gt;https://community.cisco.com/t5/devnet-sandbox/unable-to-do-rest-api-s-to-catalyst-centers/m-p/5147187/highlight/true#M10221&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2024 10:10:33 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/cisco-dnac-rest-api-call-to-retrieve-token/m-p/5148129#M8691</guid>
      <dc:creator>Marcel Zehnder</dc:creator>
      <dc:date>2024-07-22T10:10:33Z</dc:date>
    </item>
  </channel>
</rss>

