How To GET datapoints of particular Asset's particular Attribute

Hi,

Please help me to know, how can I get recent latest data (attribute value) of particular asset using HTTP API, and how can I see these data into postman response. Thanks in advance.

If you only need the most recent value, requesting the asset automatically includes
all attributes and their current values: GET /api/{realm}/asset/{id}.

You can also use POST /api​/asset​/query, which is more common.
This has a lot of configurable options to, for example, only fetch certain attributes from certain assets.

To get for example all values of the last week, you should use the datapoint query endpoint:
POST /api/{realm}/asset​/datapoint​/{assetId}​/attribute​/{attributeName}
This one is not well documented on swagger, so please ask if you need more details.

.
You can check the swagger documentation on /swagger/ on your local installation,
or check the one from our demo environment: OpenRemote Manager HTTP API Swagger UI

Dear Martin,

Thank you for you prompt reply: as you said to get current values: GET /api/{realm}/{id}

I use the same: got the response - all information is right but no attribute or it’s value shown. See the below picture

And if I am using POST method: it is giving media unsupported error as give below

Just tested the API endpoint myself on my local machine; I do get all attributes and its values.
Are you sure that the asset has attributes configured?
Does the user have the correct permission to get the attribute data?

And no you shouldn’t use POST, which is not used for that endpoint at all.
(as described in the API / swagger documentation I mentioned)

Hi Martin, Thanks for the reply … it seems attributes configured and getting data from MQTT subscribe, service user have read and write both permission. As you can see in below picture but still not getting attributes means still I am missing any thing, can you please tell me detail step to get appropriate response from API.

I guess, in attributes configuration list, we need to do some think… can you please let me know what to configure else?

It seems you have configured the ‘restricted write’ and ‘restricted read’ for that service user.
That explains what is going on :wink:

Restricted mode is meant to limit a user to only access a few assets and attributes.
By default, a restricted user does not have access to any attribute.
You need to add the Access restricted read and/or Access restricted write configuration item to the attributes you want them to access.

Hi Martin,
First of all I appreciate your support, now I am able to get current data from this API.
In case if I want to get historical data of an attribute for certain time range, how can I get this?

You should use the datapoint query endpoint for that:
POST /api/{realm}/asset​/datapoint​/{assetId}​/attribute​/{attributeName}

Specifications like time range, and lots of other configuration options,
can be included in the body of the request like this:

For example:
Using LTTB downsampling algorithm: (default)

{"type":"lttb","fromTimestamp":1688547798146,"toTimestamp":1688634198146,"amountOfPoints":50}

or
Based on interval:

{"type":"interval","fromTimestamp":1688547798146,"toTimestamp":1688634198146,"interval":"1 HOUR","gapFill":false,"formula":"AVG"}

You can change the interval, gapFill and formula (AVG/MIN/MAX) respectively ^

1 Like

Hi,
some months ago I used the API call

GET /api/{realm}/asset/datapoint/{assetId}/attribute/{attributeName}?interval=MINUTE&fromTimestamp={{fromTimestamp}}&toTimestamp={{toTimestamp}}&step=15

and everything worked perfectly fine! Now I see that it changed to POST and I need to specify my call in the body. But although I changed everything like you described, I get now 404 Not Found. Do you have any idea, what the problem could be?

Hi!

I took a look into the code, and the endpoint;
POST http://<host>/api/<realm>/asset/datapoint/<assetId>/attribute/<attributeName>

only returns a 404 when the assetId or attributeName cannot be found is not found in the database.

Or might it be the URL (or method) you used was incorrect?

Hi Martin,

thanks for your quick answer! I doublechecked everything, I can not see any errors … is the issue maybe that I am not using the latest version? I am using a version from May or June.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.