Working with Cisco PSS APIs

As I work for a Cisco Partner at the moment I have been looking to get access to the Cisco PSS APIs specifically to get coverage status on a Cisco device serial number.

If you have a Cisco account you can access the Device Coverage Checker online and check up to 20 serial numbers at a time. I have used this extensively. The same information can also be viewed if you have access to Intersight.

But I am looking to integrate with our DCIM tool Netbox to allow for easy check of coverage via API calls. Those API calls are for us available via the PSS API call to the endpoint SN2INFOv2.

Now of course this requires some sort of authentication and Cisco has an intricate process for getting access which boils down to creating a TAC case an request access.

Once you have access you need to create an application and grant that application access to the SN2INFOv2 APIs with “Client Credential” privileges. This generates a Key and a Client Secret unique to the application which is needed to get access.

Now here’s the problem. The Cisco API Developer has great documentation on the SN2INFOv2 API and how to format the request – but those need a Token to be accessed. The token needs to be generated first which was not immediately clear how to do.

I deciphered that I needed to do a OAUTH2 login agains cloudsso.cisco.com but could not find the documentation on how to format the request. I searched around to figure out how and found reference to a different API that showed an example on how to do this.

Problem was it refenced a “Client ID” which I did not seem to have. So I guessed a bit and assumed that “Client ID” must be the “Key” I had as the login required “Client ID” and “Client Secret” and I had “Key” and “Client Secret”.

So formatted the GET request but got a 405 Method not allowed. Now I was a bit lost. But searching a bit more I fell upon a dodgy PHP developer forum which I will not link to. But here was an example of a cURL request that showed me an approach. The request looked like this:

 curl -s -k -H "Content-Type: application/x-www-form-urlencoded" -X POST -d "client_id=..." -d "client_secret=..." -d "grant_type=client_credentials" https://cloudsso.cisco.com/as/token.oauth2

Now there was still reference to “Client ID” but again assumed it to be the “Key” I had and would you know – the API returned me an access token.

This access token needs to be passed on requests to the SN2INFOv2 API as:

curl -X GET -s -k -H "Accept: application/json" -H "Authorization: Bearer <TOKEN>" https://api.cisco.com/sn2info/v2/coverage/status/serial_numbers/<SERIALNUMBER>

And there you go! Easy to setup in Postman or Golang or Python or what ever you prefer!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.