cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1646
Views
0
Helpful
2
Replies

Accessing Cisco Prime API

luke.brooker1
Level 1
Level 1

Hi All - sorry i'm not too experienced with API's and development, hopefully this question is OK;

 

I am interested in using the API in Cisco Prime Infrastructure (3.7.0). Following the built in tutorial on Prime (https://Server/webacs/api/v4/?id=tutorials ) I get to this step;

 

For this tutorial, the host name of my server is "my_server". So without further ado, here's our first cURL query.

curl -k "https://user:password@my_server/webacs/api/v4/data/Devices "

 

When i try that, this is the output i get (i added the Prime Cert to my PC Trusted Certs, i'm using windows w/ PowerShell);

 

PS C:\Users\> curl "https://MyUser:MyPass@ServerIP/webacs/api/v4/data/Devices"

StatusCode : 200

StatusDescription :

Content : <!--Guidelines for i18n

Use bean:message tag for internationalization of strings.

Use dojo/i18n module to internationalize strings delivered through Dojo framework.

i18n design document ED...

RawContent : HTTP/1.1 200

X-XSS-Protection: 1; mode=block

X-Content-Type-Options: nosniff,nosniff

Content-Security-Policy: default-src https: data: 'unsafe-inline' 'unsafe-eval'

X-FRAME-OPTIONS: SAMEORIGIN

T...

Forms : {loginForm}

Headers : {[X-XSS-Protection, 1; mode=block], [X-Content-Type-Options, nosniff,nosniff],

[Content-Security-Policy, default-src https: data: 'unsafe-inline' 'unsafe-eval'],

[X-FRAME-OPTIONS, SAMEORIGIN]...}

Images : {}

InputFields : {@{innerHTML=; innerText=; outerHTML=<input name="j\_username" type="hidden">; outerText=;

tagName=INPUT; name=j_username; type=hidden}, @{innerHTML=; innerText=; outerHTML=<input

name="j_password" type="hidden">; outerText=; tagName=INPUT; name=j_password; type=hidden},

@{innerHTML=; innerText=; outerHTML=<input name="spring-security-redirect"

id="spring-security-redirect" type="hidden" value="/pages/common/index.jsp">; outerText=;

tagName=INPUT; name=spring-security-redirect; id=spring-security-redirect; type=hidden;

value=/pages/common/index.jsp}, @{innerHTML=; innerText=; outerHTML=<input name="action"

type="hidden" value="login">; outerText=; tagName=INPUT; name=action; type=hidden; value=login}}

Links : {}

ParsedHtml : mshtml.HTMLDocumentClass

RawContentLength : 11693

 

I believe I should get a list of Devices managed in Prime. I'm not sure why this is happening. The account I'm using for the API call has these permissions ticked;

 

NBI Credential

NBI Read

NBI Write

 

Any idea's or tips on what to try next?

 

Thanks !

2 Replies 2

Alex Stevenson
Cisco Employee
Cisco Employee

 

Hi @luke.brooker1,

 

The cURL example uses the -k flag (probably -K, see list-of-curl-options.txt) but it appears you left this out in your call.

 

Hope this helps!

I got this all working, i ended up using 'Postman API platform' which created the Auth details for me, and could export for use in PowerShell.. This was what i required;

 

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Basic <<Snip>>")
$headers.Add("Cookie", "JSESSIONID=<<Snip>>")

and then any API call just needed to be appended with;

 

-Method 'GET' -Headers $headers

Once i worked this bit out, everything worked fine