OH3 - rest api http request with authentication

in OH 2.5x i have a rule to check if bindings are online or offline, for example:

Thing "innogysmarthome:bridge:SMARTHOME09" received update or
System started
var response = sendHttpGetRequest("http://xxx.xxx.xxxx.x:8080/rest/things/innogysmarthome:bridge:SMARTHOME09")
var String status= transform("JSONPATH", "statusInfo.status", response)

When i try this in OH3, i get the following error:

{“error”:{“message”:“Authentication required”,“http-code”:401}}

How can i submit my user credentials in a rule in OH3?
I tried http://user:password@xxx.xxx.xxx.x but this didn’t work.

Thanks in advance for any help.

This might solve your issues

If you want to use Basic auth you have to enable it in the settings.

Thanks, but Basic Authentication is already enabled:

I wrote nonsense. Ignore this post.

Struggling with the same issue.

  • checked basic authentication
  • unchecked ‘implicite user role’

FF is now concerned that I send a user:password, and even though confirming that this is ok,
I receive also,

{"error":{"message":"Authentication required","http-code":401}}

Can you show the request you are making (with dummy pw/user)?
If it is in the form http://user:pw@oh_host:oh_port/rest.. it should definitely work

I’m using Basic Authentication and have the “Impicit user role…” checked to ON. With those settings my REST calls via a rule are working!

Yes - it works and correct setting is implicit user role to on.
Sorry - I was confused.

The problem is probably a typo in the url :wink:

I still get the error:

{“error”:{“message”:“Authentication required”,“http-code”:401}}

My request:


What could be wrong with this url? In OH 2.5 this is working fine (without user credentials).

Hi, i changed to oh3 and now my rest api ist not working anymore.

My doorphone is sending a command to oh and then oh opens the door:

Action URL inside my doorphone:$card_sn

I also added user and password like this, but no success. I get no error messages inside my log. Simply not working…$card_sn -u {oh3_adminuser}:{oh3password}

I activated basic authentication in “API-Sicherheit” inside OH3 Settings.
oh3_adminuser is the user/pass of the new admin user i made while upgrading to oh3 on first run.

This is an undocumented usage. Or rather, was an undocumented usage in OH2, doesn’t exist in OH3


I made some tests: When i change classicui to basicui it is still working.

1 Like

I managed to make this to work in rules, however I’m not happy with hard coded username/password in rules file. Is there a better solution?