cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
610
Views
0
Helpful
7
Replies

API Call to retrieve the "device specific values" csv?

SMitchell1
Level 1
Level 1

Is there an API call that can retrieve the CSV data for the device specific variable/values? The equivalent of going to vmanage > Configure > Devices > {device} > Change Device Values > Download CSV

We're migrating several dozen sites in the near future and would like to be able to obtain the current CSV data in code so I can automate updating the path values to what they are for the new devices generating a new CSV files with the new values.

2 Accepted Solutions

Accepted Solutions

What is the complete uri and payload?

View solution in original post

The spacing looks off in your payload.  should look like this if using python before applying  json.dumps

  payload = {"templateId":templateId,"deviceIds":[uuid],"isEdited":False,"isMasterEdited":False}

 

 I have used this on 20.6, 20.9 and 20.12 code.

[root@Raggedtooth cat8kv]# python templateInput.py 4f68d795-21e8-4d55-bdd5-ff4c55be8344 C8K-B5698608-998C-92DA-CFF4-EA1E77E83C3A


200
https://192.168.0.156:443/dataservice/template/device/config/input/
+-----------------------+------------------------------------------+
|          key          |                  value                   |
+-----------------------+------------------------------------------+
|  ipv6_strict_control  |                  false                   |
|      metroeIntf       |           GigabitEthernet7.100           |
|      metroeIpv6       |  2001:0172:0027:0003:0000:0000:0000:002  |
|         vbond         |             vbond2.local.net             |
|       hostName        |                cat8kv40_1                |
|     inetShaperBps     |                500000000                 |
|   advertiseNetwork    |               169.1.1.0/24               |
|       ntpLogTac       |              192.168.16.254              |
|      metroePeIp       |                172.27.3.1                |
|     lanv6Network      |                2001:40::0                |
|       mplsVlan        |                   100                    |
|     csv-host-name     |                cat8kv40_1                |
|       mplsPeIp        |                172.27.1.1                |
|       mplsIpv6        |  2001:0172:0027:0001:0000:0000:0000:002  |
|      mplsPeIpv6       |  2001:0172:0027:0001:0000:0000:0000:001  |
|     metroePeIpv6      |  2001:0172:0027:0003:0000:0000:0000:001  |
|    metroShaperBps     |                100000000                 |
|     csv-deviceId      | C8K-B5698608-998C-92DA-CFF4-EA1E77E83C3A |
|         lanIp         |                10.0.40.1                 |
| multicastGroupAddress |                225.1.1.1                 |
|        lanIpv6        |                2001:40::1                |
|     metroeTunnel      |                  100007                  |
|      metroeVlan       |                   100                    |
|      vbond1ipv6       |             2001:10:64:32::1             |
|        siteId         |                    40                    |
|       routerNum       |                    1                     |
|      vbond2ipv6       |             2001:10:64:64::1             |
|       systemIp        |                11.1.40.1                 |
|      lanNetwork       |                10.0.40.0                 |
|        mplsIp         |                172.27.1.2                |
|       mplsIntf        |           GigabitEthernet3.100           |
|     csv-deviceIP      |                11.1.40.1                 |
|      csv-status       |                 complete                 |
|      tunnelIntf       |                  100003                  |
|     mplsShaperBps     |                200000000                 |
|       vbond1ip        |                10.100.1.1                |
|       vbond2ip        |                10.200.1.1                |
|       metroeIp        |                172.27.3.2                |
+-----------------------+------------------------------------------+
200
https://192.168.0.156:443/dataservice/template/device/config/input/

 

View solution in original post

7 Replies 7

Dan Frey
Cisco Employee
Cisco Employee

The API to get the variable list returned as JSON and can be converted to csv on the client end.

        payload = {"templateId":templateId,"deviceIds":[uuid],"isEdited":False,"isMasterEdited":False}
        api_url = "/template/device/config/input/"
        url = base_url + api_url
        response = requests.post(url=url, headers=headers, data=json.dumps(payload), verify=False)

 

Thanks! I'll try this out in a bit and update. 

So I tried forming the request in postman and keep getting a 500 internal server error response. I've tried different combinations of forming my request body in json format but I'm not having much luck. This is not a multitenant environment, if that matters at all.

 

{
    "error": {
        "message": "Server error",
        "details": "vManage server experience an unexpected error,If the problem persists, please contact your administrator for details.",
        "code": "REST0001"
    }
}

What is the complete uri and payload?

For security purposes on a public forum, I need to redact my base url and the specific deviceId and templateId, but they are in the proper format, as other requests leveraging them work and I know the base URL is correct because I have made several dozen different calls successfully. This is the first one I'm running into an issue with

POST:        https://{BASE-URL}/dataservice/template/device/config/input/

Request body put into body field in postman as raw, format: JSON

{
    "templateId" : "{{templateId}}",
    "deviceIds" : "{{device-uuId}}",
    "isEdited" : False,
    "isMasterEdited" : False
}
 
I've tried tinkering with the body in different ways, quotes on the values, no quotes, quotes on the boolean values, no quotes, wrapping the body in a second pair of curly braces because that is what's on the API reference, thought I'm pretty sure that's just broken HTML.
 
EDIT:
For what it's worth, I tried to run the call in Python as well and got this in the "response.text":
 
<html><head><title>Error</title></head><body>HTTP method POST is not supported by this URL</body></html>
 
If I try any other method, it throws an error and tells me that only POST is supported for this method...I do have full read/write to this SDWAN instance.

The spacing looks off in your payload.  should look like this if using python before applying  json.dumps

  payload = {"templateId":templateId,"deviceIds":[uuid],"isEdited":False,"isMasterEdited":False}

 

 I have used this on 20.6, 20.9 and 20.12 code.

[root@Raggedtooth cat8kv]# python templateInput.py 4f68d795-21e8-4d55-bdd5-ff4c55be8344 C8K-B5698608-998C-92DA-CFF4-EA1E77E83C3A


200
https://192.168.0.156:443/dataservice/template/device/config/input/
+-----------------------+------------------------------------------+
|          key          |                  value                   |
+-----------------------+------------------------------------------+
|  ipv6_strict_control  |                  false                   |
|      metroeIntf       |           GigabitEthernet7.100           |
|      metroeIpv6       |  2001:0172:0027:0003:0000:0000:0000:002  |
|         vbond         |             vbond2.local.net             |
|       hostName        |                cat8kv40_1                |
|     inetShaperBps     |                500000000                 |
|   advertiseNetwork    |               169.1.1.0/24               |
|       ntpLogTac       |              192.168.16.254              |
|      metroePeIp       |                172.27.3.1                |
|     lanv6Network      |                2001:40::0                |
|       mplsVlan        |                   100                    |
|     csv-host-name     |                cat8kv40_1                |
|       mplsPeIp        |                172.27.1.1                |
|       mplsIpv6        |  2001:0172:0027:0001:0000:0000:0000:002  |
|      mplsPeIpv6       |  2001:0172:0027:0001:0000:0000:0000:001  |
|     metroePeIpv6      |  2001:0172:0027:0003:0000:0000:0000:001  |
|    metroShaperBps     |                100000000                 |
|     csv-deviceId      | C8K-B5698608-998C-92DA-CFF4-EA1E77E83C3A |
|         lanIp         |                10.0.40.1                 |
| multicastGroupAddress |                225.1.1.1                 |
|        lanIpv6        |                2001:40::1                |
|     metroeTunnel      |                  100007                  |
|      metroeVlan       |                   100                    |
|      vbond1ipv6       |             2001:10:64:32::1             |
|        siteId         |                    40                    |
|       routerNum       |                    1                     |
|      vbond2ipv6       |             2001:10:64:64::1             |
|       systemIp        |                11.1.40.1                 |
|      lanNetwork       |                10.0.40.0                 |
|        mplsIp         |                172.27.1.2                |
|       mplsIntf        |           GigabitEthernet3.100           |
|     csv-deviceIP      |                11.1.40.1                 |
|      csv-status       |                 complete                 |
|      tunnelIntf       |                  100003                  |
|     mplsShaperBps     |                200000000                 |
|       vbond1ip        |                10.100.1.1                |
|       vbond2ip        |                10.200.1.1                |
|       metroeIp        |                172.27.3.2                |
+-----------------------+------------------------------------------+
200
https://192.168.0.156:443/dataservice/template/device/config/input/

 

Oh wow, getting rid of all the whitepsace fixed it in Postman. 3 hours of my day spent on whitespace. Thank you!

Review Cisco Networking for a $25 gift card