Update restdocs.md (#1050)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>pull/1051/head
parent
637d2aa20e
commit
96c0e79195
|
@ -28,25 +28,35 @@ Nevertheless, here is some examples using [curl](https://en.wikipedia.org/wiki/C
|
|||
- Switching ```My_Item``` OFF by issuing an http [POST](https://en.wikipedia.org/wiki/POST_(HTTP)) request:
|
||||
|
||||
```java
|
||||
curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "OFF" "http://ip_openHAB_host:8080/rest/items/My_Item"
|
||||
curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "OFF" "http://{openHAB_IP}:8080/rest/items/My_Item"
|
||||
```
|
||||
|
||||
- Setting a Contact item ```My_Item``` to CLOSED by issuing an http PUT request to ```My_Item/state```:
|
||||
|
||||
```java
|
||||
curl -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "CLOSED" "http://ip_openHAB_host:8080/rest/items/My_Item/state"
|
||||
curl -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "CLOSED" "http://{openHAB_IP}:8080/rest/items/My_Item/state"
|
||||
```
|
||||
|
||||
- Retrieving a list of all Items and Groups by issuing a GET request:
|
||||
|
||||
```java
|
||||
curl -X GET --header "Accept: application/json" "http://ip_openHAB_host:8080/rest/items?recursive=false"
|
||||
curl -X GET --header "Accept: application/json" "http://{openHAB_IP}:8080/rest/items?recursive=false"
|
||||
```
|
||||
|
||||
- Retrieving a list of all sitemaps by issuing a GET request:
|
||||
|
||||
```java
|
||||
curl -X GET --header "Accept: application/json" "http://192.168.1.35:8080/rest/sitemaps"
|
||||
curl -X GET --header "Accept: application/json" "http://{openHAB_IP}:8080/rest/sitemaps"
|
||||
```
|
||||
|
||||
- Subscription to events:
|
||||
|
||||
```java
|
||||
// ThingStatusInfoChangedEvent - The status of a thing changed.
|
||||
curl "http://{openHAB_IP}:8080/rest/events?topics=smarthome/things/{thingUID}/statuschanged"
|
||||
|
||||
// ChannelTriggeredEvent - A channel has been triggered.
|
||||
curl "http://{openHAB_IP}:8080/rest/events?topics=smarthome/channels/{channelUID}/triggered"
|
||||
```
|
||||
|
||||
The commands above have been copied from the REST API documentation for illustration.
|
||||
|
@ -55,7 +65,8 @@ The commands above have been copied from the REST API documentation for illustra
|
|||
|
||||
The REST API documentation is available on your openHAB installation as a custom user interface.
|
||||
|
||||
You can add it by opening the PaperUI interace, clicking "Add-ons", selecting "Misc". You will see an addon called "REST Documentation" that can be easily installed.
|
||||
You can add it by opening the PaperUI interace, clicking "Add-ons", selecting "Misc".
|
||||
You will see an addon called "REST Documentation" that can be easily installed.
|
||||
|
||||
On the welcome screen of openHAB, you will now see a new interface called "REST API" where you can easily see the documentation of the REST API and test it!
|
||||
|
||||
|
@ -66,5 +77,5 @@ All available commands will be displayed in the REST API documentation as a resp
|
|||
|
||||
The REST API also supports server-push supporting subscriptions on change notification for certain resources.
|
||||
|
||||
One final remark - when openHAB’s REST API is accessed from another domain the following error may be encountered: [No 'Access-Control-Allow-Origin' header is present on the requested resource](https://community.openhab.org/t/cors-problem-at-rest-api/3712/10).
|
||||
In this case, it may be necessary to add the line org.eclipse.smarthome.cors:enable=true in the file services/runtime.cfg.
|
||||
One final remark - when openHAB's REST API is accessed from another domain the following error may be encountered: [No 'Access-Control-Allow-Origin' header is present on the requested resource](https://community.openhab.org/t/cors-problem-at-rest-api/3712/10).
|
||||
In this case, it may be necessary to add the line `org.eclipse.smarthome.cors:enable=true` in the file `services/runtime.cfg`.
|
||||
|
|
Loading…
Reference in New Issue