Webservices fromDate example?

Hi,

I want to know how to interrogate the AirVantage db to retrieve several of my data points back from one application on a device for a certain time range, i.e. get values for a, b, c for fromDate to toDate.

I’ve beed referring to the API https://doc.airvantage.net/av/reference/cloud/API/ to Export data history:

POST https://na.airvantage.net/api/v1/operations/systems/{uid}/export/data/historical
Content-Type: application/json
...
{
    "dataset" : "3ed6cd7426604ee0bca9fe01f2521230",
    "data" : ["_RSSI", "261"],
    "fromDate" : "1341093600",
    "toDate" : "1341180000"
}

I’m using curl to run the query but I am getting errors on the data field. What do I use here? I know my data points and I have tried them here, such as aaa.bbbb.cccc (per the path in datamodel.data) but I get an error “dataset.unknown”. Also, what is the “261” in the above example? I was expecting to provide a list of dataId paths such as used in this command: eu.airvantage.net/api/v1/system … targetIds={uid}&dataIds=cbmP.sensor.AreaD,cbmP.sensor.DPr&access_token={token}

Also, I suspect my timestamps are being used wrong, as obtained from a raw dump if I use a timestamp via “curl eu.airvantage.net/api/v1/systems/{uid}/messages?fromDate=1442532292&access_token={token} | jq” I get the error:

{
  "error": "system.invalid.timerange",
  "errorParameters": []
}

Any assistance would be appreciated.

Regards,
Steve

Hi Steve,

timestamp must be supplied in ms. So you just have to add 000 at the end of your fromDate value and it will work (by the way this parameter is deprecated, use from parameter instead).

I guess the sample for export historical data is not correct. I will check later and update it accordingly.
A dataSet is not a data path. It is a set of data you define in Configure > Reports. Create your report, give it a name and get the uuid to use it in this API.

261 is just a path for a data! According to some use case, … you can find a lot of things. _XXXX are data which can be used by the platform to display the value in the Monitor > Systems > System detail view. See the list in the API doc, in System > Fields tab (in the top of the page)

In data, as you correctly understood, you have to supply data Ids.

I hope I answered to all your question. Don’t hesitate to come back if it is not clear or if you have new questions.

Regards,
Robert

Hi Robert,

I configured a report to retrieve all my data and scheduled it to run every hour. I followed this guide : https://doc.airvantage.net/av/reference/configure/howtos/retrieveDataInAReport/.

I’m unsure of the sequence of calls to make after this or if the report has a uuid. Did you mean I should use the report uuid value in the dataset? Do I really need a report or can I query the M3DA data?

My report has items called AreaD, Cd, DPppl among 40 others. Does this mean I can use the following?

"data" : ["AreadD", "Cd", "DPppl"],

Regards,
Steve

Yes. You can get this uuid from the url when you display the details of a report.

You may consider these two items:

  • your systems send data to AirVantage which store them. You can use report, in this case, AirVantage asks to the system to send the value of this set of data (have a look to the API called ‘Retrieve Data’ in System section and all API in the ‘Dataset’ section). Your system can push data automatically on AirVantage as well.

  • you want to get the data values stored in AirVantage. You may want to have a look to Operations > Systems > System > Data:

  • Last datapoints

  • Multi Raw datapoints

  • Multi Aggregated datapoints

  • Fleet Aggregated datapoints

  • Export datapoints

Yes you can use a list of dataId but the data Id format is not correct.
Data Id is the full path of your data, to be sure it identify uniquely your data.
That means you have to start with the asset-id. Have a look to your application model (the xml file which describes your data).
You will find something like that:

<asset default-label="FTP Monitoring" id="greenhouse">
	      	<node path="data" default-label="Data">
				<variable path="temp" type="int" default-label="Temperature"/>
				<variable path="hum" type="int" default-label="Humidity"/>
			</node>
<variable path="temp" type="int" default-label="External Temperature"/>
</asset>

The dataId are greenhouse.data.temp which identifies the Temperature.
But you can get greenhouse.temp which identifies the External Temperature.

Hmm. I think we should add this explanation in the API Howto into the doc.

Regards,
Robert

Hi Robert,

Thanks, I’ve had some success with:

request csv for report

curl -H “Content-Type: application/json” -X POST -d ‘{“dataset” : “2c7370c4cf0c42ee8e18a23d2e20e52e”, “fromDate” : “1441563032000”,“toDate” : “1442921079000”}’ eu.airvantage.net/api/v1/operations/systems/{uid}/export/data/historical?access_token=${naccess_token}

request csv for datapoints

curl -H “Content-Type: application/json” -X POST -d ‘{“data” : [“cbmP.sensor.DPt”, “cbmP.sensor.DPr”, “cbmP.sensor.DPppl”],“fromDate” : “1441563032000”,“toDate” : “1442921079000”}’ eu.airvantage.net/api/v1/operations/systems/{uid}/export/data/historical?access_token=${naccess_token}

I also had to make sure I chose a report that was had retrieved data!

Regards,
Steve