cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
783
Views
0
Helpful
1
Replies

API REST v4 - metrics intraffic TIME_SERIES - no returning data

ipcarlos
Level 1
Level 1

Hi everyone! I hope you're fine,

I'm trying to perform some automations using Python 3 scripts and the Cisco Rest API v4

I'm trying to get interfaces metric data (https://developer.cisco.com/site/prime-infrastructure/documents/api-reference/latest/v4/op/statisticsService/interfaces/metrics/%7Bmetric%7D-GET@_docs/

The next line for being specific (using Long for measuring from 01 Dec 2022 to 31 Dec 2022):

"https://" + ip + "/webacs/api/v4/op/statisticsService/interfaces/metrics/intraffic.json?startTime=" + start_time + "&endTime=" + end_time +"&metricDataType=TIME_SERIES&device=" + router_ip + "&ifName=" + router_interface

And I'm getting no data (Attached an image of this), but, if I replace the parameters startTime and endTime using timeInterval I get data...

Not sure why is this happening

I'm totally new to the API, so I don't know if something has to be installed or activated in the router (my knowledge about networks is not much)

Hope you can give me a hand 

Thank you so much for your time!

Best regards

1 Reply 1

Alexander Stevenson
Cisco Employee
Cisco Employee

Hi @ipcarlos,

 

I''m not an expert with Prime or this API but I'm experienced with Python and APIs in general, so these are just my thoughts...

So it looks like the startTime and endTime parameters must be of 'Long' type. My understanding is that we could convert an Integer to Long type in Python2, but Long and Integer types have been merged in Python3. Essentially, all Integers are also Longs in Python3. So, the format of the numbers isn't the issue I think.

Have you tried receiving the response in XML format instead of JSON?

I'm not sure if this is applicable, but have you tried changing the values for these parameters?

 

AlexStevenson_1-1676652792903.png

You could also trying moving the timestamps to the end of the Request. The example they have adds the time parameter to the end of the request

 

https://localhost/webacs/api/v4/op/statisticsService/interfaces/metrics/{metric}.json?device=192.168.0.1&ifName=GigabitEthernet0/1&timeInterval=1