Hi everyone:
I am a new comer to the SmartApp platform. When using httpGet() in a demo, I always encountered an error: java.lang.SecurityException: Endpoint null is blacklisted.
I have done a research over many similar posts here but still cannot figure out why my code is not working. Can you guys help me and provide some guidance?
Thanks so much!
My code:
/**
* Make API calls from a SmartApp
*
*/
definition(
name: "Make API calls from a SmartApp",
namespace: "com.smartthings.dev",
author: "SmartThings Hack",
description: "Make REST calls inside a SmartApp.",
category: "My Apps",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
oauth: true)
preferences {
section("Title") {
// TODO: put inputs here
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
initialize()
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
initialize()
}
def initialize() {
try {
httpGet(params) { resp ->
resp.headers.each {
log.debug "${it.name} : ${it.value}"
}
def theHeaders = resp.getHeaders("Content-Length")
log.debug "response contentType: ${resp.contentType}"
log.debug "response status code: ${resp.status}"
log.debug "response data: ${resp.data}"
}
} catch (e) {
log.debug "something went wrong: $e"
}
}
def params = [
uri: "http://httpbin.org",
path: "/get"
]