VMware Communities
icbryant9
Contributor
Contributor

API call to get Link Data

Using the API Request I am trying to retrieve Link information.  WHen I make the API Request 
https://{api_host}//api/sdwan/v2/enterprises/{enterpriseLogicalId}/edges/{edgeLogicalId}/linkStats

I am only getting 

{ "autoDualMode": "string", "bestJitterMsRx": 0, "bestJitterMsTx": 0, "bestLatencyMsRx": 0, "bestLatencyMsTx": 0, "bestLossPctRx": 0, "bestLossPctTx": 0, "bpsOfBestPathRx": 0, "bpsOfBestPathTx": 0, "bytesRx": 0, "bytesTx": 0, "controlBytesRx": 0, "controlBytesTx": 0, "controlPacketsRx": 0, "controlPacketsTx": 0, "link": { "_href": "string"}, "name": "string"

How can I make it get all the details in the link nested dict like shown here 
https://developer.vmware.com/apis/vmware-sase-platform/vmware-sdwan/latest/api/sdwan/v2/enterprises/...

Code for reference

def get_edge_link_metrics():

endpoint = f'https://{api_host}//api/sdwan/v2/enterprises/{enterpriseLogicalId}/edges/{edgeLogicalId}/linkStats'

head = {'Authorization': f'token {myToken}'}

response = requests.get(endpoint, headers=head,)
if response.status_code == 200:
# Successful response, you can process the data here
data = response.json()
print(data)


else:
# Handle errors
print(f"Error: {response.status_code} - {response.text}")



get_edge_link_metrics()



Reply
0 Kudos
4 Replies
Gizzie
Enthusiast
Enthusiast

After some searching around, I've found this:

print(data['link'])
Reply
0 Kudos
icbryant9
Contributor
Contributor

Yeah this is what I have been trying.  But it will only return the _href': value.  The rest of the dict is empty.  I tried this on multiple velcloud devices with multiple links and none of it works.  print(data[0]["link"]) Mention data[0] for Link 1.  output below

 

====== RESTART: C:\Users\ib311515\Desktop\Sitestatus\Velocloud_api_pt3.py ======
{'_href': '/api/sdwan/v2/enterprises

icbryant9_1-1691078385706.png

 

 

 

Reply
0 Kudos
khirom
Enthusiast
Enthusiast

How about using Postman?
It helps to verify the response.

I got link data using Postman.
My test steps are below.

1. Get Enterprise Logical ID
I got my enterpse logicalId via API v1.

Request: Post

"https://<vco-fqdn>/portal/rest/enterprise/getEnterprise"

I got enterpriseLogicalId like this.
xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx


2. Get Edge Logical ID
I got my edge logicalId via API v1.

Request: Post

https://<vco-fqdn>/portal/rest/enterprise/getEnterpriseEdges

I got edgeLogicalId like this.
yyyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyy


3. Get Link stats
Request: Get
https://{vco-fqdn}//api/sdwan/v2/enterprises/
{enterpriseLogicalId}/edges/{edgeLogicalId}/linkStats

Reply
0 Kudos
icbryant9
Contributor
Contributor

Yeah I tried Postman as well, same issue.  I think there is an issue with the API request itself.  Weird that it would only return one item in the Nested Dictionaries

 

 

icbryant9_0-1691184953904.png

 

Reply
0 Kudos