How can I retrive the list of dataItems for a specific asset using the API?
The <server>/services/v2/rest/dataItem/find only support modelNumber, name and type as criteria.
If there are many assets that are using the same model the query will return all the dataItems from all assets using the model.
Solved! Go to Solution.
In my example, the asset I have has 5 "current" data items in the asset dashboard, and the model has 12 configured data items. Though my request returns *ALL* model data items, only the "current" data items will have a <v2:value> element in the response data.
with Query Body:
This API is behaving as expected, and only populated data is being presented to you with your request.
Value will be null/not-present for any data item that isn't valid on that Asset, but that is present on the Model.
Please note that data items are model based and that all assets share the list of data items from the model they belong to.
Now based on the asset, those data items will change based on thresholds and other changes.
You could query each asset for their specific data item values both current or historical.
I know I can query each asset for their data item values. I am looking for the list of the dataItems for a specific device/asset. Is there a way to get this?
Assuming you have the systemId of the asset, might not the following meet your needs?
Theoretically yes, it will be a good workaround and I can parse the items list from the response.
Unfortunately is returning the list of all dataItems associated with the model that is mapped with the assetId.
Any other suggestions are welcome.
The following seemed to work for me:
Depending on how tight your time window is will determine how many data items get returned. Each dataitem could return multiple values of itself depending on retention history and activity.
In my case the Dashboard shows 5 data items for this asset, and this query returns 5 data items.
This is working in a way, it is true this only returns dataItemsValues for the current Asset but the dataItems are repeating and since I have many values in response ("totalCount" : 63010 until now) it will be kinda awkward parse it all to create a set of 5 unique dataItems ...
The solution with /services/v2/rest/dataItem/findCurrentValues was perfect if it was working.
Current values is the way to go. If an asset has a data item, the most recent value will appear in the current table. With historical, it had to have been received within the date range. And the query will probably be less efficient since the table can be much larger.
Current values is returning the list of all dataItems associated with the model that is mapped with the assetId ...