[SOLVED] Update Item through REST API

You need to use POST instead of GET requests:

 /usr/bin/curl  -q --user  '<your user account>:<your password>' --header "Content-Type: text/plain" --request POST --data "ON" http://192.168.56.11:8080/rest/items/CameraGarageMotion
1 Like

Restdocs is a user interface addon that lets you navigate the API and get answers back to help you determine the URL and parameters needed for your devices. You see the results in real time.

At https://github.com/openhab/openhab1-addons/wiki/Samples-REST you find a list of commands for different programming languages.

That’s a really old resource that is not complete nor completely accurate for OH 2. The REST API Docs add-on (installable from the UIs tab in PaperUI) will be the correct and up to date docs. It includes the curl command for each endpoint which one should be able to use to generate the rest.

This is where I am getting confused. I am not sending it though any code, just a field in the NVR that takes a URL. Is it not possible to do what I want with REST?

@shady9191

This is not official but it is running, maybe in OH3 this will not run anymore.

http://192.168.56.11:8080/classicui/CMD?CameraGarageMotion=ON
1 Like

Classic UI is already slated to be removed from OH3 when the new UI is included.

That worked!!

1 Like

Would be happy if someone could provide a solution that will work with OH3.

Here we help people develop their own solutions. I have led you to where I would find the answer. If you are not motivated enough to try I cannot help further.

Hey Buddy, I don’t appreciate that response. And yes, I did install the REST doc and spent almost an hour playing around. I hit a wall, so I thought ask for help. Is this not why the forums exist?

In OH3 it requires a PUT or a POST. You can’t do it with a GET. Not directly at least. You might be able to put together an HTML page that converts a GET to a PUT/POST. See OAuth2 using just OH Rules and myopenhab.org for an example doing something like that.

1 Like

Thanks. I was just taking a look at this:

I also applied to Vivotek to get access to their SDK. We sell their cameras, so they should approve me!! :slight_smile:

So I went a completely different route. The camera has the ability to send an image to an FTP server when motion is detected. I then used the ftp binding:

Now OpenHAB gets notification when there is motion, and gets an image :slight_smile:

That only works if the FTP server can be reached. If interested there is a way to do this with the ipcamera binding, by entering the right URL in to your NVR it will trigger the alarm channel you can trigger the INSTAR alarm server and from memory that is with get requests. Can provide info if interested.

Very interested. Will read through:

Then setup the camera as a INSTAR thing type and override all the urls so they match your cameras.

Then do a get request, you can easily test it by entering it into any browser.

http://openhabIP:SERVER_PORT/instar?&active=7

That will make the motion alarm get triggered.

Hey Bryan
No sweat
feel free to ask questions

1 Like

Good Day Guys,
Just a quick question regarding the REST API, Is there any way to pass an event origin parameter to rest API and get it back from the event streaming API. What I want to do is differentiate the events coming from openhab and connected devices vs events coming back form the updates I sent from REST to avoid loops.
Cheers
Roshan

Please don’t ask the same question on multiple threads. Ideally, this should have been asked as it’s own thread. See the other place you posted this question for the answer.