Using REST API ? no response on 2.1.0

I have an Arduino which collects temperature data from my boiler. I have been posting this to Xively but they have discontinued the service. I’d like to start posting to my OpenHAB 2.1 rrd4j database where I am already collecting data from some power monitors.
I’m trying to use the OpenHAB REST API which I have installed and access at ip:8080/rest/swagger.json
The first thing I did was try to look at the items which I have installed using GET /persistence/items however this gives and empty response body [ ]. (I get the same empty response body from the REST API)
Hard to go much further if I can’t see what’s going on here. I’ve found a few other people who seem to have the same problem but they have not had any resolution.
Is the RES API working in 2.1.0?

As far as I’m aware the REST API works just fine in 2.1.

So the questions become:

  • Do you have rrd4j persistence installed?
  • Is your rrd4j.persist file correct?
  • Are there errors in your log?
  • Do you have any files in /var/lib/openhab2/persistence/rrd4j?
  • Have you confirmed that rrd4j is working some other way (e.g. through a Rule using lastUpdate or historicState)?

Next let’s move on to the REST calls.

Do you have the REST Documentation installed and are you issuing your queries from there to experiment? I ask because the call to get all your Items is GET http://ip:8080/rest/items. To get the list of all Items that are persisted would be GET http://ip:8080/rest/persistence/items. Though I do find that when I attempt to run this from the REST Docs I too am getting the empty list for persisted Items.

So in general, the REST API does appear to work. But this one call doesn’t. But getting and putting persistence data on individual Items does work.

I should note, the “proper” way to post this data to OH would be to create an Item or Items to represent the data and set those Items up to persist to the DB rather than posting to the rrd4j DB directly.

Thanks for this information.
I have the rrd4j persistence installed and I have a few devices (Z-wave energy monitors) reporting to it and I have a few charts set up in HABmin which work just fine so it seems to be working.
I do have the REST documentation installed and am using that page to test my queries
I’m using the GET /persistence/items on that page and get nothing in the response (and when I try the same thing on the demo.openhab page I also get nothing.
I haven’t tried to create any items since I’m flying blind here and can’t see my items.

Thanks for the tip on the proper way to post to OH is by creating items and posting to them. I believe that is what I am trying to do but I’m blind as to the items.
I guess I’ll just go ahead and create an item and hope I can post to it.

If you are calling for items in REST Api without detailing the persistence AND without a default persistence service set you will get an empty return.

Just looking through the REST API and there doesn’t seem to be a way to add a persistence item using the API.
I can GET, PUT and delete data from an item but how do I add a new persistence item?

If I use the GET /items API, it lists all of my items including the persistence items.
The persistence items are not tagged as persistence items… ? should they be.

I tried it both ways. With the default and with the names of both of the persistence engines I’m using. I always got an empty return.

Like I said above, to see your Items, whether or not they are

There is no such thing as a “persistence item”. You have Items. Some Items might be configured to be persisted but there is nothing different about the Item. The configuration is on the Persistence, not on the Item. There is nothing different about posting a value to an Item that is persisted verses one that is not through the REST API. You need to focus on the Items section of the API. Ignore the persistence section.

Items get updated or commanded. That update or command gets published on the Event Bus. If the Persistence Engine sees an update or a command for an Item that it is configured to save to the DB, it grabs the value and creates an entry in the DB.

I must have set up these power monitor items to have persistence (since I can get charts of historical values) but I can’t figure out how I did it. (Sorry, I’m new at this and it’s a bit overwhelming.)
In looking at my persistence/rrd4j folder, it seems that every item has a persistence rrd file. It just seems to do this by default.
How do you configure an item to be saved to the database?.. or not?

The call I was referring to was GET Persistence Items [Itemname]
Yes, it seems impossible to get a list of the persited items, however you can check each item for its entries in the database.

So, my rrd4j.persist file is this:
Strategies {
// for rrd charts, we need a cron strategy
everyMinute : “0 * * * * ?”

    default = everyChange


Items {
* : strategy = everyUpdate, everyMinute

I guess this is the default and seems to set up persistence for every item. For now, this is fine with me.

Thanks for all your help. Hopefully I’ll be able to sort things out from here.