REST API Remotely in iOS Shortcuts App

Has anyone figured out how to get the iOS Shortcuts app to work with REST API remotely? The thread below shows how to get it to work locally, but they never were able to get it to work remotely.

What I’m trying to do is operate a light (or any switch) while away from my house. I have verified that it should work by logging into myopenhab.org and testing with the REST API documentation web interface.

Also, I know the url string I’m using should work because I can paste it into the Safari browser on the same iPhone and I get a return status from the openHAB switch item. I used the url string method from the thread below.

I feel like it’s not authenticating properly in the Shortcuts app, but I don’t know why. It doesn’t return any error, it just runs the shortcut indefinitely with no feedback. Any help would be appreciated.

The last time I tried to do something like this on an iOS device it could not work because Apple does not allow one to save a shortcut that includes the basic auth as part of the URL. Without that there is no login information so myopenhab.org rightly blocks the attempt.

You will need to either find some app that allows you to provide/define the basic auth information or find some other way.

1 Like

Thanks Rich. That’s what I was afraid of.

Maybe it would be possible using this App.

Can be done. Found this: https://www.reddit.com/r/shortcuts/comments/a02hni/httpbasicauth_for_get_requests/
Basically you need to encode credentials user:pass with Base64, then add a request header Authorization, containing Basic Base64Credentials. The reddit link above contains a further link to a sample shortcut on iCloud: https://www.icloud.com/shortcuts/7c081f97f731455b8cffeb32cbd0718b
My use case is changing the state of an item on https://home.myopenhab.org/rest/items/_myItem, works fine.

1 Like