Blog Post

Tech Talk
1 MIN READ

Device DataSource Instance datapoint historical data using RestAPI v3

Cole_McDonald's avatar
Cole_McDonald
Icon for Professor rankProfessor
9 months ago

I am having problems getting the RestAPI to return any data regardless the combination of paths, query params, time filters I try using.  What am I doing wrong?  Here’s my ultimate URL I’ve built for this effort:

$ddsi is a successfully retrieved object (DeviceDataSourceInstance)

Start and End are from these:

    [int]$start = get-date (get-date).addMonths(-3) -uformat %s
    [int]$end   = get-date (get-date).addMonths(-3).AddMinutes(5) -uformat %s

/device/devices/$($ddsi.deviceid)/devicedatasources/$($ddsi.devicedatasourceid)/data?size=500&offset=0&start=$start&end=$end&datapoints=Capacity,PercentUsed

All of the pieces and parts seem to line up with examples I’ve found here and in the LM Docs… it doesn’t error out, but returns nothing.

Goal is to get volume capacity metrics from 3 months ago.

Where am I going awry here?  Everything works up until I add the /data at the end.

Published 9 months ago
Version 1.0

25 Comments

  • Right, LM needs to flip some flags when they generate the swagger docs. I just put in a feed for it, but the more the merrier.

    Really, there’s no reason, now that we have bearer tokens, to be able to do what swagger does in their example. Notice the “try it out” buttons on each call. 

  • Is there a way to get the DeviceDatasourceID as a built in variable from the platform?  That would save a ton of API overhead.  Then I can just grab the instances from that and get my historical data using the DDI’s properties.  I don’t find anything in the LM Docs that state this for use in dataSources, I do find them for alerts though.

    I can get the deviceid and the instanceid, but not the datasourceid… from the restAPI, I can access the device and the dataSource, but not the instance… so I have to get the devicedatasource to get to the instance no matter how I slice it.  That adds an extra uneccesary API call that could be a single pre-filtered call.

    I’ll put in a feedback for the direct instance access as I would prefer that since we seem to have that ID as an instance level token as ##system.instanceid##  I would expect there to be a ##system.devicedatasourceid## that we could reach now to get the necessary IDs for filling out the URL to the instance.

  • Is there a way to get the DeviceDatasourceID as a built in variable from the platform? 

    Not that i’m aware.