DX NetOps Manager

Tech Tip: Calling OpenAPI/odata query from curl 

05-12-2017 04:29 AM

The easiest way to call a OpenAPI/odata query from a shell script is via curl command. However,  some aspects need to be considered to make it work.

 

Syntax 
curl -u user:password -G -X GET -d 'parameters' 'URL'

  • URL is the portion before the ? in the original odata query, parameters is the portion after
  • both URL and parameters need to be enclosed in single quotes
  • parameters string has substitution characters such as %20 for blank. Simply copy the odata query to Chrome, it will perform the conversion. Then copy the string from the Chrome line.
    (you will need to verify your odata query anyway) 

 

Example:

curl -u myuser:mypassword -G -X GET -d '$apply=groupby(ID,%20aggregate(portmfs(im_BitsIn%20with%20percentile95%20as%20im_BitsIn),portmfs(im_BitsOut%20with%20percentile95%20as%20im_BitsOut)))&starttime=1490594251&endtime=1493186251&resolution=RATE&$select=ID,Name&$filter=((substringof(%27CA%27,Name)%20eq%20true))&$format=text/csv' 'http://DA-HOST:8581/odata/api/groups'

Statistics
0 Favorited
9 Views
0 Files
0 Shares
0 Downloads

Related Entries and Links

No Related Resource entered.