cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
650
Views
10
Helpful
3
Replies

vManage API GET Request Authentication Failures

michaelshirazi
Level 1
Level 1

Hello,

I am having an issue where none of my vManage GET requests are working. 

This is how I am authenticating:

 

curl --location -g -k -i --request POST 'https://{IP}/j_security_check' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'j_username=Myusername' \
--data-urlencode 'j_password=MyPassword'

 

This is the header response I am getting:

 

HTTP/1.1 200 OK
set-cookie: JSESSIONID=r9814df98g18d9wIOHhCbS5Q7y_jU.b501fb51-djfg90-90gdf4; path=/; secure; HttpOnly
x-xss-protection: 1; mode=block
pragma: no-cache
x-frame-options: DENY
date: Wed, 14 Sep 2022 20:12:54 GMT
vary: Accept-Encoding
strict-transport-security: max-age=31536000; includeSubDomains
x-content-type-options: nosniff
content-length: 0
server: svcproxy

 

Ok so far everything looks good right? Now here is when I try running a GET request:

 

curl --location -g -k --request GET 'https://{ip}/dataservice/template/policy/vedge/devices' --header 'Content-Type: application/json' --header 'Cookie: JSESSIONID=r9814df98g18d9wIOHhCbS5Q7y_jU.b501fb51-djfg90-90gdf4'

 

And finally, here is a small snippet of the failed auth response that I get:

 

                <!-- show the notice message here -->
            </div>
            <div id="error-info-container">
                <div id="error-info">
                    <div id="errorInfoIcon" name="errorInfoIcon" class="errorInfoIcon">
                        <img src="/images/error.svg" alt="Login Error">
                    </div>
                    <div id="errorInfoText">
                  

 

 

As you can see, I'm getting Login Errors, despite having the session ID added to my GET request headers. Anyone know what I'm doing wrong? I've tried ALOT of different iterations of this and can't get anything to work.

Thanks

 

3 Replies 3

Alex Stevenson
Cisco Employee
Cisco Employee

Hi @michaelshirazi,

I found something interesting at https://developer.cisco.com/docs/sdwan/#!authentication/how-to-authenticate

 

Note:

API requests header for GET/POST/PUT/DELETE are

For vManage pre-19.2 - Session Cookie (jsessionid)
For vManage post-19.2 - Session Cooke (jsessionid) and Token

 

So, if using post-19.2 vManage, you need to provide XSRF token as such:

 

https://{vmanage-ip-address}/dataservice/{api-endpoint-url}
Content-Type: application/json
HTTP Header: "Cookie: JESSIONID={session hash id}" "X-XSRF-TOKEN: {XSRF token}"

 

Some other ideas would be to try double quotes in your cURL request or try running the the request from Postman or from inside code (Postman can generate the code for you).

 

@michaelshirazi @Alex Stevenson the best way to do this on version 19.2 and later is as follows, using the Developer SD-WAN SBX as an example (update your tokens as required) use this command for obtaining a token in string format

 

 

❯ curl --user devnetuser:RG'!'_Yw919_83 https://sandbox-sdwan-1.cisco.com/dataservice/client/token --insecure
9BE6E408BD930FF1F1FE46C98D80C56DCB5CCD32FAA3F2BFAC319D0AD7E6E02393BBF7A1F00608948AD35BBB70BEABEA86F7

 

 In the header of each subsequent API request in the current session, include the key X-XSRF-TOKEN key, with a value that consists of the token that you generated. Here i am using the API to display all devices in the overlay network that are connected to the vManage instance. GET https://{vmanage-ip-address}/dataservice/device

 

❯ curl --user devnetuser:RG'!'_Yw919_83 "https://sandbox-sdwan-1.cisco.com/dataservice/device" -H "Cookie:JSESSIONID=pSwrx3AEWokiDO1TkFiOjgSehp-ITNdFn7Xj9PsL.c331d01e-91d7-41cc-ab90-b629c2ae6d97" --insecure -H "X-XSRF-TOKEN=9BE6E408BD930FF1F1FE46C98D80C56DCB5CCD32FAA3F2BFAC319D0AD7E6E02393BBF7A1F00608948AD35BBB70BEABEA86F70"
{"header":{"generatedOn":1672654336938,"viewKeys":{"uniqueKey":["system-ip"],"preferenceKey":"grid-Device"},"columns":[{"title":"Hostname","property":"host-name","display":"iconAndText","iconProperty":"device-type","hideable":false,"icon":[{"key":"vmanage","value":"images/vmanage_table.png"},{"key":"vedge","value":"images/vedge_table.png"},{"key":"vedge-vbond","value":"images/vedge-vbond_table.png"},{"key":"vsmart","value":"images/vsmart_table.png"},{"key":"vbond","value":"images/vbond_table.png"}],"width":150,"dataType":"string"},{"title":"State","property":"state","display":"iconAndToolTip","iconProperty":"state","toolTipProperty":"state_description","defaultPropertyKey":"reachability","defaultPropertyValue":"reachable","icon":[{"key":"green","value":"images/device_state_green.png"},{"key":"red","value":"images/device_state_red.png"},{"key":"yellow","value":"images/device_state_yellow.png"},{"key":"default","value":"images/device_state_other.png"}],"width":20,"dataType":"string"},{"title":"System IP","property":"system-ip","hideable":false,"width":110,"dataType":"ipv4"},{"title":"Reachability","property":"reachability","display":"multiColumns","color":[{"key":"reachable","value":"616161","property":"reachability"},{"key":"unreachable","value":"ef5350","property":"reachability"},{"key":"auth-failed","value":"ffb300","property":"reachability"},{"key":"staging","value":"ffb300","property":"validity"}],"width":150,"minWidth":150,"dataType":"string"},{"title":"Site ID","property":"site-id","width":70,"dataType":"numberStr"},{"title":"Device Model","property":"device-model","display":"multiColumns","hideable":false,"width":100,"dataType":"deviceModel"},{"title":"BFD","property":"bfdSessions","width":75,"minWidth":65,"dataType":"numberStr"},{"title":"Control","property":"controlConnections","width":75,"minWidth":65,"dataType":"numberStr"},{"title":"Version","property":"version","width":150,"dataType":"string"},{"title":"Up Since","property":"uptime-date","displayFormat":"DD MMM YYYY h:mm:ss A z","inputFormat":"unix-time","width":200,"dataType":"date"},{"title":"Chassis Number/ID","property":"uuid","hideable":false,"width":220,"dataType":"string"},{"title":"Device Groups","property":"device-groups","width":100,"dataType":"array"},{"title":"Connected vManage","property":"connectedVManages","width":500,"dataType":"array"}],"fields":[{"property":"host-name","dataType":"string","display":"iconAndText"},{"property":"state","dataType":"string","display":"iconAndToolTip"},{"property":"system-ip","dataType":"ipv4"},{"property":"reachability","dataType":"string","display":"multiColumns"},{"property":"site-id","dataType":"numberStr"},{"property":"device-model","dataType":"deviceModel","display":"multiColumns"},{"property":"bfdSessions","dataType":"numberStr"},{"property":"controlConnections","dataType":"numberStr"},{"property":"version","dataType":"string"},{"property":"number-vsmart-peers","dataType":"number"},{"property":"uptime-date","dataType":"date"},{"property":"uuid","dataType":"string"},{"property":"board-serial","dataType":"string"},{"property":"device-groups","dataType":"array"},{"property":"connectedVManages","dataType":"array"},{"property":"lastupdated","dataType":"date"}]},"data":[{"deviceId":"10.10.1.1","system-ip":"10.10.1.1","host-name":"vmanage","reachability":"reachable","status":"normal","personality":"vmanage","device-type":"vmanage","timezone":"UTC","device-groups":["\"No groups\""],"lastupdated":1672419412441,"domain-id":"0","board-serial":"No certificate installed","certificate-validity":"Not Applicable","max-controllers":"0","uuid":"81ac6722-a226-4411-9d5d-45c0ca7d567b","controlConnections":"0","device-model":"vmanage","version":"19.2.2","connectedVManages":["\"10.10.1.1\""],"site-id":"101","latitude":"37.666684","longitude":"-122.777023","isDeviceGeoData":false,"platform":"x86_64","uptime-date":1672417920000,"statusOrder":4,"device-os":"next","validity":"valid","state":"green","state_description":"All daemons up","model_sku":"None","local-system-ip":"10.10.1.1","total_cpu_count":"2","testbed_mode":false,"layoutLevel":1},{"deviceId":"10.10.1.5","system-ip":"10.10.1.5","host-name":"vsmart","reachability":"unreachable","status":"normal","personality":"vsmart","device-type":"vsmart","timezone":"UTC","device-groups":["\"No groups\""],"lastupdated":1590088369679,"domain-id":"1","board-serial":"4E500CAE354B4341B322C5DA4BD7588A","certificate-validity":"Valid","uuid":"f7b49da3-383e-4cd5-abc1-c8e97d345a9f","controlConnections":"--","device-model":"vsmart","version":"19.2.2","connectedVManages":[],"site-id":"101","ompPeers":"--","latitude":"37.666684","longitude":"-122.777023","isDeviceGeoData":false,"platform":"x86_64","uptime-date":1590088260000,"statusOrder":4,"device-os":"next","validity":"valid","state":"green","state_description":"All daemons up","model_sku":"None","local-system-ip":"10.10.1.5","total_cpu_count":"0","testbed_mode":false,"layoutLevel":2},{"deviceId":"10.10.1.3","system-ip":"10.10.1.3","host-name":"vbond","reachability":"unreachable","status":"normal","personality":"vbond","device-type":"vbond","timezone":"UTC","device-groups":["\"No groups\""],"lastupdated":1590088368621,"board-serial":"7AC124B4AED648EB99B9900DD56A405C","certificate-validity":"Valid","uuid":"ed0863cb-83e7-496c-b118-068e2371b13c","controlConnections":"--","device-model":"vedge-cloud","version":"19.2.2","connectedVManages":[],"site-id":"101","ompPeers":"--","latitude":"37.666684","longitude":"-122.777023","isDeviceGeoData":false,"platform":"x86_64","uptime-date":1590088200000,"statusOrder":4,"device-os":"next","validity":"valid","state":"green","state_description":"All daemons up","model_sku":"None","local-system-ip":"10.10.1.3","total_cpu_count":"4","linux_cpu_count":"1","testbed_mode":false,"layoutLevel":3}]}

 

 It looks kinda ugly, so if you end your curl with '| json_pp' this comes out something cleaner

 

❯ curl --user devnetuser:RG'!'_Yw919_83 "https://sandbox-sdwan-1.cisco.com/dataservice/device" -H "Cookie:JSESSIONID=pSwrx3AEWokiDO1TkFiOjgSehp-ITNdFn7Xj9PsL.c331d01e-91d7-41cc-ab90-b629c2ae6d97" --insecure -H "X-XSRF-TOKEN=9BE6E408BD930FF1F1FE46C98D80C56DCB5CCD32FAA3F2BFAC319D0AD7E6E02393BBF7A1F00608948AD35BBB70BEABEA86F70"| json_pp
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5804    0  5804    0     0   6067      0 --:--:-- --:--:-- --:--:--  6083
{
   "data" : [
      {
         "board-serial" : "No certificate installed",
         "certificate-validity" : "Not Applicable",
         "connectedVManages" : [
            "\"10.10.1.1\""
         ],
         "controlConnections" : "0",
         "device-groups" : [
            "\"No groups\""
         ],
         "device-model" : "vmanage",
         "device-os" : "next",
         "device-type" : "vmanage",
         "deviceId" : "10.10.1.1",
         "domain-id" : "0",
         "host-name" : "vmanage",
         "isDeviceGeoData" : false,
         "lastupdated" : 1672419412441,
         "latitude" : "37.666684",
         "layoutLevel" : 1,
         "local-system-ip" : "10.10.1.1",
         "longitude" : "-122.777023",
         "max-controllers" : "0",
         "model_sku" : "None",
         "personality" : "vmanage",
         "platform" : "x86_64",
         "reachability" : "reachable",
         "site-id" : "101",
         "state" : "green",
         "state_description" : "All daemons up",
         "status" : "normal",
         "statusOrder" : 4,
         "system-ip" : "10.10.1.1",
         "testbed_mode" : false,
         "timezone" : "UTC",
         "total_cpu_count" : "2",
         "uptime-date" : 1672417920000,
         "uuid" : "81ac6722-a226-4411-9d5d-45c0ca7d567b",
         "validity" : "valid",
         "version" : "19.2.2"
      },
      {
         "board-serial" : "4E500CAE354B4341B322C5DA4BD7588A",
         "certificate-validity" : "Valid",
         "connectedVManages" : [],
         "controlConnections" : "--",
         "device-groups" : [
            "\"No groups\""
         ],
         "device-model" : "vsmart",
         "device-os" : "next",
         "device-type" : "vsmart",
         "deviceId" : "10.10.1.5",
         "domain-id" : "1",
         "host-name" : "vsmart",
         "isDeviceGeoData" : false,
         "lastupdated" : 1590088369679,
         "latitude" : "37.666684",
         "layoutLevel" : 2,
         "local-system-ip" : "10.10.1.5",
         "longitude" : "-122.777023",
         "model_sku" : "None",
         "ompPeers" : "--",
         "personality" : "vsmart",
         "platform" : "x86_64",
         "reachability" : "unreachable",
         "site-id" : "101",
         "state" : "green",
         "state_description" : "All daemons up",
         "status" : "normal",
         "statusOrder" : 4,
         "system-ip" : "10.10.1.5",
         "testbed_mode" : false,
         "timezone" : "UTC",
         "total_cpu_count" : "0",
         "uptime-date" : 1590088260000,
         "uuid" : "f7b49da3-383e-4cd5-abc1-c8e97d345a9f",
         "validity" : "valid",
         "version" : "19.2.2"
      },
[removed]

 

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

Alex Stevenson
Cisco Employee
Cisco Employee

Thank you @bigevilbeard,

Your functioning example makes this very clear!

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: