Perform HTTP GET Request towards local server

I want to write a smartapp to get same data from a local server and pass these on DH.

When I trying with the code below:

def params = [
        uri: ""
try {
	httpGet(params) { resp ->
    def data = "$".toString()
    log.debug (data)


Am getting the following error:

something went wrong: java.lang.SecurityException: Endpoint is blacklisted.

After browsing the web, I found that ST hub prevent this action because the web server is a local IP address and not external.

Is there any workaround or an alternative method to get the requested data from the local web server?

This requires you to go through the hub. For example:

sendHubCommand(new physicalgraph.device.HubAction("""GET $path HTTP/1.1\r\nHOST: $host\r\n\r\n""", physicalgraph.device.Protocol.LAN, null, [callback: cbk]))

Thanks for your replay.

After modifying the code to:

def Host = ""
sendHubCommand(new physicalgraph.device.HubAction("""GET HTTP/1.1\r\nHOST: $Host\r\n\r\n""",physicalgraph.device.Protocol.LAN, null, [callback: cbk]))


void cbk(physicalgraph.device.HubResponse hubResponse) {
log.debug "Entered calledBackHandler()..."
def body = hubResponse
log.debug (body)

The response is:

19:11:14: debug Entered calledBackHandler()…

19:07:44: debug physicalgraph.device.HubResponse(index:BF, mac:B827EB7B760F, ip:0A000A1D, port:1F90, requestId:52ab43e5-eac2-41e3-ae7a-1fad9f47ea7a, hubId:edb6007d-322b-43e2-bcde-924d5175d1ff, callback:cbk)

Normally I should get these HTML data as a response:

ZP1B Sensor Data

data1: 11111

data2: 2222.2

data3: 33.3333

I can’t figure out how to save the responsed html data to variable “body” :confused:

A simpler way:

def hubAction = new physicalgraph.device.HubAction(
                method: "GET",
                path: "",
                [callback: callbackParse]


void callbackParse(physicalgraph.device.HubResponse hubResponse) {
    log.debug "Body: ${hubResponse.body}"

Unfortunately i cant make it to work.

I got an "java.lang.NullPointerException: Cannot get property ‘id’ on null object” error.
Is it possible to share a sample code please?

I want to make the get requests towards '


I was able to make it work:

def sendCmd(evt){
	def deviceIP = “"
	def cmdStr = new physicalgraph.device.HubAction([
		method: "GET",
		path: "",
		headers: [
			HOST: "${deviceIP}:8080"
		[callback: callbackParse]

void callbackParse(physicalgraph.device.HubResponse hubResponse) {
   def data = hubResponse.body.toString()
   log.debug (data)

Thanks guys for the help :slight_smile: