Accessing item via rest API via myopenhab

Hi all,

to be able to render the location map ( also from remote in the native application I tried to access the location values via rest using … in the html; but it fails - I assume my.openHAB does not allow CORS (cross domain calls):

XMLHttpRequest cannot load No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://haus:8080' is therefore not allowed access. The response had HTTP status code 401.

Would it make sense to enable such requests, or is this too much of a security risk? Is there another way I can make the map work in the native apps (unfortunately there’s no location widget)?

with kind regards,

That is correct

I’d have to think about it but my first inclination is this would be a pretty big security risk if not done really well. Jetty may not support it also, which would be technical challenge.

It seems that myopenhab doesn’t support CORS neither.

Using this code:

var request = $.ajax
            type       : "POST",
            url        :  "",
            data       : "ON",
            contentType: 'text/plain',
            headers    : { 'Access-Control-Allow-Origin':'*' }

I get following error:

No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

Do you know how to bypass this? When posting the request using Postman I have no problem at all but I must say I am not familiar with CORS yet.

Is there a solution to the issue?

I was also interessted into this use case and tested it. For me it worked fine to access openHAB via REST via myopenhab.

I tried two use cases:

  1. Get the state of an item
  2. Set the state of an item

Two ways of connection I tried:

My system setup:

  • openhabian on an Raspberry Pi connected via LAN
  • openhabian connected via openHAB cloud connector to the myopenhab cloud
  • I have one Thing with one Item (switch) set up via the Modbus binding
  • For testing REST I’m using the Mac App “Insomnia Core” (

My Insomnia Core setup for GET STATE:

My Insomnia Core setup for POST STATE:

This setup doesn’t work for me. Does anyone have any idea how I can access the REST api via myopenhab?

        <script src=""></script>
        <button id="ajax">ajax call</button>
        <script type="text/javascript">
                     type: "GET",
                     username: "", 
                     password: "xxx",
                     url: "",
                     success: function(data){        

I get the same error as described in the first post. Is there any other way to access items from “outside”?