07-16-2024 06:42 PM
Hi,
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 someone direct me to the right direction?
===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)
07-17-2024 12:24 AM - edited 07-17-2024 12:27 AM
hi @tnakano03
You can register you app here https://apiconsole.cisco.com/
You can also find steps described that you need to follow to get your OAuth2 secrets here: https://apiconsole.cisco.com/docs/read/overview/Platform_Introduction
Another useful resource is documentation itself: https://developer.cisco.com/docs/support-apis/user-onboarding-process/
I hope this helps.
07-18-2024 05:34 AM
Hi mfr-6,
Thank you for the information.
I would like to access "https://api.cisco.com/sn2info/v2/coverage/{serial_number}".
However, on the "Register an Application" page (URI: https://apiconsole.cisco.com/apps/register), I can only select the following APIs. I don't see the "sn2info" API. Which API do I need to select, or does Cisco have another page to register for the "sn2info" API?
Thank you,
Toshi
07-18-2024 06:00 AM
@tnakano03 i would open this support here https://community.cisco.com/t5/smart-net-total-care-portal-and-collector-discussions/bd-p/4891-discussions-smart-net-total-care the team will ask you to 1:1 them the following:
- Email/Cisco ID needing to be Delegated administrator
- Company name:
- Company Physical Address
- Contract Associated
07-19-2024 05:18 AM
Hi bigevilbeard,
Thank you. I will look into the smart-net-total-care-portal-and-collector-discussions.
Toshi
07-18-2024 05:48 AM
hi @tnakano03
Based on docs, you need to be a part of Cisco Smart Net Total Care (SNTC) customer or Cisco Partner Support Service (PSS) partners.
https://developer.cisco.com/docs/support-apis/user-onboarding-process/#user-onboarding-process
I believe this is why you cannot get credentials for Support APIs.
07-19-2024 05:25 AM
Hi mfr-6,
Thank you for the additional information.
I work for a Managed Service Provider that manages many enterprise customers, and the account has their Cisco contract numbers and device serial numbers. We are also a Cisco partner. So, I thought the account was already part of SNTC or PSS. However, I am not sure how to check if the account has SNTC or PSS entitlement. I will look into more details.
Thanks!
07-20-2024 08:15 PM
No worries! If your company is a Cisco Partner, then for sure person who takes care of relationship with Cisco will help you. Also you can ask Cisco Support API Team to help you figure out steps to get your account set up so you can generate credentials on your own
apix-support@cisco.com
07-21-2024 07:44 AM
Thank you mfr-6. Yes I send a request to apix-support@cisco.com as well.
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