07-20-2024 01:19 PM
I would like to get Smartnet coverage information via the Cisco API. I need to generate the API key using my client_id and client_secret. However, I don't know where to set up or register my client_id and client_secret. Can you direct me to the right direction?
https://apiconsole.cisco.com/apps/register
I tried to register “api.cisco.com/sn2info” API but it is not listed here. I see only following APIs to register. How can I enable sn2ifo API?
===Python example
import requests
def get_access_token(client_id, client_secret):
url = "https://id.cisco.com/oauth2/default/v1/token"
headers = {
"Content-Type": "application/x-www-form-urlencoded"
}
body = {
"grant_type": "client_credentials",
"client_id": client_id,
"client_secret": client_secret
}
response = requests.post(url, headers=headers, data=body)
if response.status_code == 200:
token_info = response.json()
return token_info['access_token']
else:
return {"error": response.status_code, "message": response.text}
def check_smartnet_coverage(serial_number, api_key):
url = f"https://api.cisco.com/sn2info/v2/coverage/{serial_number}"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
coverage_info = response.json()
return coverage_info
else:
return {"error": response.status_code, "message": response.text}
# Replace with your actual client_id and client_secret
CLIENT_ID = "your_client_id_here"
CLIENT_SECRET = "your_client_secret_here"
# Get the access token
access_token = get_access_token(CLIENT_ID, CLIENT_SECRET)
if "error" not in access_token:
# Replace with your actual serial number
SERIAL_NUMBER = "your_serial_number_here"
coverage_info = check_smartnet_coverage(SERIAL_NUMBER, access_token)
print(coverage_info)
else:
print(access_token)
Solved! Go to Solution.
07-20-2024 02:07 PM
There should be an option to select "Serial Number to Information API Version 2". It seems that you might be missing authorization to access this API. You can contact support at supportapis-help@cisco.com
07-20-2024 02:07 PM
There should be an option to select "Serial Number to Information API Version 2". It seems that you might be missing authorization to access this API. You can contact support at supportapis-help@cisco.com
07-20-2024 04:04 PM
Hi Torbjørn,
Thank you for your reply. Yes I sent email to supportapis-help@cisco.com as well.
07-22-2024 05:59 AM
Hello,
Thank you for contacting Cisco.
In this case, besides contacting API support team, you also need to confirm that you have the proper role to register and access APIs.
I would like to get more details about this, can you please provide the following information?
• Company name:
• Company address:
• CCOID of the one trying to access API:
• Email of the one trying to access API:
You can send me a private message if you prefer that way.
Kind Regards,
Enrique Ramirez
07-29-2024 05:06 AM
Closing post due to inactivity.
07-29-2024 05:56 AM
Update:
I sent my API access request email to supportapis-help@cisco.com and I received the "Serial Number to Information API Version 2". access in my apps.
Thank you,
Toshi
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide