OH3 - Google Geocoding API addresses

I’m trying to get address info from a Google API request.

I’ve been trying to copy another post, but most of it didn’t work.

I have my location as lat,long (so excluding the altitude) to get the right url that I have tested to work in a browser window.

I am now getting stuck on the line with sendHttpGetRequest
In my log it says
[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID '1d8843e2eb' failed: ReferenceError: "sendHttpGetRequest" is not defined in <eval> at line number 5

This is my code

var home_location = (xx.xxxxxxxxxxxxx,-x.xxxxxxxxxxxxxxx)
var phone_location = ir.getItem("iPhone_Location").state.latitude + "," + ir.getItem("iPhone_Location").state.longitude

var geocodeURL = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + phone_location + "&key=" + "AIzaSyAxpvzRNxzCj1tmjkidhjduAO3YkWWwOQYI"
var gecodeResponse = sendHttpGetRequest(geocodeURL)
var formattedAddress = transform("JSONPATH", "$.results[0].formatted_address", gecodeResponse)

events.postUpdate("iPhone_Address", formattedAddress)

Could this help?

What kind of rule is this, javascript? You can’t mix and match DSL with javascript, the Actions are not available in the same way.
I think it’s something like
var gecodeResponse = Actions.sendHttpGetRequest(geocodeURL)

EDIT oh wait, more to it than that I think

Sorry, just an adventurous amature here. I don’t even really know the difference between DSL and javascript. Or which I should be using for best results.

I thought it might be something like that.

I’m not sure I understand this, but I’ll try and hack it out later when I have some time to fail.


did you create the rule using the UI, or is it defined in a .rules file? If you create your action using the UI make sure you select “Rule DSL” and not “ECMAScript”.

If it is a rules file please post the whole file content (w/o api key of course), maybe I can see something.

with kind regards,

I have been using ECMA script in the UI.
I nearly have my VS Code thingy setup and would like to use that in the future.