<?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: unable to retrieve UC certificate info using API in Management</title>
    <link>https://community.cisco.com/t5/management/unable-to-retrieve-uc-certificate-info-using-api/m-p/5064306#M4209</link>
    <description>&lt;P&gt;Not an expert here, looking atthe error message you received, it seems that the&amp;nbsp;service&amp;nbsp;parameter in the request body is not being recognized by the API. It looks like you are passing the&amp;nbsp;service&amp;nbsp;parameter as a separate dictionary in the request body, instead of as a key-value pair. I updated the&amp;nbsp;service&amp;nbsp;parameter and now this is passed as a key-value pair in the&amp;nbsp;body&amp;nbsp;dictionary, which should be correctly interpreted by the API.&lt;/P&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import requests

def getTomcat(hostname, username, password):
    body = {"service": "CAPF"}
    response = requests.get(
                            url=''.join(('https://', hostname, '/platformcom/api/v1/certmgr/config/csr')),
                            headers= {"Content-Type": "application/json"},
                            auth= (username, password),
                            json= body,
                            verify=False
                            )
    print(response)
    print(response.json())
#
if __name__=="__main__":
     getTomcat("10.10.20.1", "admin","pw")&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Apr 2024 10:09:11 GMT</pubDate>
    <dc:creator>bigevilbeard</dc:creator>
    <dc:date>2024-04-10T10:09:11Z</dc:date>
    <item>
      <title>unable to retrieve UC certificate info using API</title>
      <link>https://community.cisco.com/t5/management/unable-to-retrieve-uc-certificate-info-using-api/m-p/5063900#M4208</link>
      <description>&lt;P&gt;I am trying to retrieve certficate information against the Cisco sandbox collaboration 14.0.&lt;/P&gt;
&lt;P&gt;Here is my python code&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;SPAN&gt;def &lt;/SPAN&gt;&lt;SPAN&gt;getTomcat&lt;/SPAN&gt;(hostname&lt;SPAN&gt;, &lt;/SPAN&gt;username&lt;SPAN&gt;, &lt;/SPAN&gt;password):&lt;BR /&gt;    body = {&lt;SPAN&gt;"service"&lt;/SPAN&gt;: &lt;SPAN&gt;"CAPF"&lt;/SPAN&gt;}&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;    response = requests.get(&lt;BR /&gt;                            &lt;SPAN&gt;url&lt;/SPAN&gt;=&lt;SPAN&gt;''&lt;/SPAN&gt;.join((&lt;SPAN&gt;'https://'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;hostname&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'/platformcom/api/v1/certmgr/config/csr'&lt;/SPAN&gt;))&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;                            &lt;SPAN&gt;headers&lt;/SPAN&gt;= {&lt;SPAN&gt;"Content-Type"&lt;/SPAN&gt;: &lt;SPAN&gt;"application/json"&lt;/SPAN&gt;}&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;                            &lt;SPAN&gt;auth&lt;/SPAN&gt;= (username&lt;SPAN&gt;, &lt;/SPAN&gt;password)&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;                            &lt;SPAN&gt;json&lt;/SPAN&gt;= body&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;                            &lt;SPAN&gt;verify&lt;/SPAN&gt;=&lt;SPAN&gt;False&lt;BR /&gt;&lt;/SPAN&gt;                            )&lt;BR /&gt;    &lt;SPAN&gt;print&lt;/SPAN&gt;(response)&lt;BR /&gt;    &lt;SPAN&gt;print&lt;/SPAN&gt;(response.json())&lt;BR /&gt;&lt;SPAN&gt;#&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;if &lt;/SPAN&gt;__name__==&lt;SPAN&gt;"__main__"&lt;/SPAN&gt;:&lt;BR /&gt;     getTomcat(&lt;SPAN&gt;"10.10.20.1"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"admin"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"pw"&lt;/SPAN&gt;)&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;Here is the reference I used&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developer.cisco.com/docs/certificate-management/#!api-reference" target="_blank" rel="nofollow noopener noreferrer"&gt;https://developer.cisco.com/docs/certificate-management/#!api-reference&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;It returned error code 400 as below&lt;/P&gt;
&lt;P&gt;&amp;lt;Response [400]&amp;gt;&lt;BR /&gt;{'key': 400, 'messages': ['Invalid Service Name!'], 'trackingID': 'UC_5680397f-0fa9-4271-bcc2-0e194de0b5a6'}&lt;/P&gt;
&lt;P&gt;Is there anything else I am missing?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2024 06:42:16 GMT</pubDate>
      <guid>https://community.cisco.com/t5/management/unable-to-retrieve-uc-certificate-info-using-api/m-p/5063900#M4208</guid>
      <dc:creator>cxu21</dc:creator>
      <dc:date>2024-04-10T06:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: unable to retrieve UC certificate info using API</title>
      <link>https://community.cisco.com/t5/management/unable-to-retrieve-uc-certificate-info-using-api/m-p/5064306#M4209</link>
      <description>&lt;P&gt;Not an expert here, looking atthe error message you received, it seems that the&amp;nbsp;service&amp;nbsp;parameter in the request body is not being recognized by the API. It looks like you are passing the&amp;nbsp;service&amp;nbsp;parameter as a separate dictionary in the request body, instead of as a key-value pair. I updated the&amp;nbsp;service&amp;nbsp;parameter and now this is passed as a key-value pair in the&amp;nbsp;body&amp;nbsp;dictionary, which should be correctly interpreted by the API.&lt;/P&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import requests

def getTomcat(hostname, username, password):
    body = {"service": "CAPF"}
    response = requests.get(
                            url=''.join(('https://', hostname, '/platformcom/api/v1/certmgr/config/csr')),
                            headers= {"Content-Type": "application/json"},
                            auth= (username, password),
                            json= body,
                            verify=False
                            )
    print(response)
    print(response.json())
#
if __name__=="__main__":
     getTomcat("10.10.20.1", "admin","pw")&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2024 10:09:11 GMT</pubDate>
      <guid>https://community.cisco.com/t5/management/unable-to-retrieve-uc-certificate-info-using-api/m-p/5064306#M4209</guid>
      <dc:creator>bigevilbeard</dc:creator>
      <dc:date>2024-04-10T10:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: unable to retrieve UC certificate info using API</title>
      <link>https://community.cisco.com/t5/management/unable-to-retrieve-uc-certificate-info-using-api/m-p/5068420#M4211</link>
      <description>&lt;P&gt;Thank you for your reply.&lt;/P&gt;
&lt;P&gt;The comma behind the service parameter is one of the problems, the python won't run if it is there, I do not know why it was there, probably it is a typo when I post the script.&lt;/P&gt;
&lt;P&gt;The invalid service name error is related to the variable name in the get request, if I change "json" to "params", it will work.&lt;/P&gt;
&lt;DIV&gt;
&lt;PRE&gt;response = requests.get(&lt;BR /&gt;                        &lt;SPAN&gt;url&lt;/SPAN&gt;=&lt;SPAN&gt;''&lt;/SPAN&gt;.join((&lt;SPAN&gt;'https://'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;hostname&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'/platformcom/api/v1/certmgr/config/csr'&lt;/SPAN&gt;))&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;                        &lt;SPAN&gt;headers&lt;/SPAN&gt;= {&lt;SPAN&gt;"Content-Type"&lt;/SPAN&gt;: &lt;SPAN&gt;"application/json"&lt;/SPAN&gt;}&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;                        &lt;SPAN&gt;auth&lt;/SPAN&gt;= (username&lt;SPAN&gt;, &lt;/SPAN&gt;password)&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;                        &lt;STRONG&gt;params&lt;/STRONG&gt;= body&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;                        &lt;SPAN&gt;verify&lt;/SPAN&gt;=&lt;SPAN&gt;False&lt;BR /&gt;&lt;/SPAN&gt;                        )&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Apr 2024 23:42:26 GMT</pubDate>
      <guid>https://community.cisco.com/t5/management/unable-to-retrieve-uc-certificate-info-using-api/m-p/5068420#M4211</guid>
      <dc:creator>cxu21</dc:creator>
      <dc:date>2024-04-13T23:42:26Z</dc:date>
    </item>
  </channel>
</rss>

